Combatant

Combatant modules for Minecraft 26.2: 95 modules across 5 categories, each with its complete source file.

Minecraft 26.295 modulesJava216 mixins

Mixins (216)

Every mixin Combatant ships, complete and verbatim, with the vanilla classes it modifies. Target links open that class in the site source browser.

ProfilersMixinsrc/dev/java/combatant/client/mixins/ProfilersMixin.javaJava · 26 lines · 955 B
@Mixin(Profiler.class)
ModifiesProfiler
ProfilersMixin.javaJava · 26 lines · 955 B · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import net.minecraft.util.profiling.InactiveProfiler;
4
import net.minecraft.util.profiling.Profiler;
5
import net.minecraft.util.profiling.ProfilerFiller;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.injection.At;
8
import org.spongepowered.asm.mixin.injection.Inject;
9
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
10
import combatant.client.render.engine.profiler.DevTracyProfiler;
11
12
@Mixin(Profiler.class)
13
public abstract class ProfilersMixin {
14
15
    @Inject(method = "getDefaultFiller", at = @At("HEAD"), cancellable = true)
16
    private static void combatant$limitVanillaTracyToRenderThread(CallbackInfoReturnable<ProfilerFiller> cir) {
17
        if (!DevTracyProfiler.isEnabled()) {
18
            return;
19
        }
20
        if (DevTracyProfiler.shouldTraceCurrentThread()) {
21
            return;
22
        }
23
        cir.setReturnValue(InactiveProfiler.INSTANCE);
24
    }
25
}
26
AbstractClientPlayerMixinsrc/main/java/combatant/client/mixins/AbstractClientPlayerMixin.javaJava · 124 lines · 4.4 KB
@Mixin(AbstractClientPlayer.class)
AbstractClientPlayerMixin.javaJava · 124 lines · 4.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.player.AbstractClientPlayer;
12
import net.minecraft.util.Mth;
13
import net.minecraft.world.effect.MobEffects;
14
import net.minecraft.world.entity.ai.attributes.Attributes;
15
import net.minecraft.world.item.ItemStack;
16
import net.minecraft.world.item.Items;
17
import org.spongepowered.asm.mixin.Mixin;
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.callback.CallbackInfo;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
23
import combatant.client.features.module.Modules;
24
import combatant.client.features.module.modules.combat.PvpCooldowns;
25
import combatant.client.features.module.modules.visuals.FovControl;
26
import combatant.client.util.pvp.CooldownRegistry;
27
import combatant.client.util.pvp.PvpTargetState;
28
import combatant.client.util.pvp.opponents.OpponentCooldownManager;
29
30
@Mixin(AbstractClientPlayer.class)
31
public class AbstractClientPlayerMixin {
32
33
34
    @Unique
35
    private boolean combatant$wasUsing = false;
36
37
    @Inject(method = "getFieldOfViewModifier", at = @At("HEAD"), cancellable = true)
38
    private void combatant$overrideFovMultiplier(boolean changingFov, float fovEffectScale,
39
                                                 CallbackInfoReturnable<Float> cir) {
40
        FovControl module = Modules.get(FovControl.class);
41
        if (module == null || !module.isEnabled()) return;
42
43
        AbstractClientPlayer player = (AbstractClientPlayer) (Object) this;
44
45
        float f = 1.0f;
46
47
        if (player.getAbilities().flying && !module.disableFlyingFov()) {
48
            f *= 1.1f;
49
        }
50
51
        boolean skipSpeed = module.disableSprintFov() && player.isSprinting();
52
        if (module.disableSpeedFov() && player.hasEffect(MobEffects.SPEED)) skipSpeed = true;
53
        if (module.disableSlownessFov() && player.hasEffect(MobEffects.SLOWNESS)) skipSpeed = true;
54
55
        if (!skipSpeed) {
56
            float walkSpeed = player.getAbilities().getWalkingSpeed();
57
            if (walkSpeed != 0.0f) {
58
                float attr = (float) player.getAttributeValue(Attributes.MOVEMENT_SPEED);
59
                float speedFactor = attr / walkSpeed;
60
                f *= (speedFactor + 1.0f) / 2.0f;
61
            }
62
        }
63
64
        if (player.isUsingItem()) {
65
            if (player.getUseItem().is(Items.BOW)) {
66
                if (!module.disableBowFov()) {
67
                    float use = player.getTicksUsingItem() / 20.0f;
68
                    use = Math.min(use, 1.0f);
69
                    f *= 1.0f - (Mth.sqrt(use) * 0.15f);
70
                }
71
            } else if (changingFov && player.isScoping()) {
72
                if (!module.disableSpyglassFov()) {
73
                    cir.setReturnValue(0.1f);
74
                    return;
75
                }
76
            }
77
        }
78
79
        float mult = Mth.lerp(fovEffectScale, 1.0f, f);
80
81
        float expand = Math.max(0.0f, module.getExpandScale());
82
        float shrink = Math.max(0.0f, module.getShrinkScale());
83
        if (mult > 1.0f) {
84
            mult = 1.0f + (mult - 1.0f) * expand;
85
        } else if (mult < 1.0f) {
86
            mult = 1.0f - (1.0f - mult) * shrink;
87
        }
88
89
        cir.setReturnValue(mult);
90
    }
91
92
    @Inject(method = "tick", at = @At("TAIL"))
93
    private void combatant$trackEat(CallbackInfo ci) {
94
        AbstractClientPlayer p = (AbstractClientPlayer) (Object) this;
95
        Minecraft mc = Minecraft.getInstance();
96
97
        if (mc.player == null || p == mc.player) {
98
            combatant$wasUsing = p.isUsingItem();
99
            return;
100
        }
101
102
        boolean using = p.isUsingItem();
103
104
        PvpCooldowns mod = Modules.get(PvpCooldowns.class);
105
        if (mod == null || !mod.isSystemEnabled() || !PvpTargetState.isTargetInPvp(p.getUUID())) {
106
            combatant$wasUsing = using;
107
            return;
108
        }
109
110
        if (using && !combatant$wasUsing) {
111
            ItemStack stack = p.getUseItem();
112
            if (!stack.isEmpty() && CooldownRegistry.isTracked(stack.getItem())) {
113
                OpponentCooldownManager.recordUse(p.getUUID(), stack.getItem());
114
            }
115
        }
116
117
        combatant$wasUsing = using;
118
    }
119
}
120
121
122
123
124
AbstractContainerScreenMixinsrc/main/java/combatant/client/mixins/AbstractContainerScreenMixin.javaJava · 30 lines · 1.1 KB
@Mixin(AbstractContainerScreen.class)
AbstractContainerScreenMixin.javaJava · 30 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Inject;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
15
import combatant.client.features.module.Modules;
16
import combatant.client.features.module.modules.movement.InventoryMove;
17
18
@Mixin(AbstractContainerScreen.class)
19
public abstract class AbstractContainerScreenMixin {
20
21
    @Inject(method = "onClose", at = @At("HEAD"), cancellable = true)
22
    private void combatant$inventoryMove$deferClose(CallbackInfo ci) {
23
        InventoryMove module = Modules.get(InventoryMove.class);
24
        if (module == null || !module.isEnabled()) return;
25
        if (module.shouldCancelHandledScreenClose((AbstractContainerScreen<?>) (Object) this)) {
26
            ci.cancel();
27
        }
28
    }
29
}
30
AbstractSelectionListMixinsrc/main/java/combatant/client/mixins/AbstractSelectionListMixin.javaJava · 39 lines · 1.5 KB
@Mixin(AbstractSelectionList.class)
AbstractSelectionListMixin.javaJava · 39 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.GuiGraphicsExtractor;
11
import net.minecraft.client.gui.components.AbstractSelectionList;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
17
18
@Mixin(AbstractSelectionList.class)
19
public abstract class AbstractSelectionListMixin {
20
21
    @Inject(method = "enableScissor(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V", at = @At("HEAD"))
22
    private void combatant$pushScissor(GuiGraphicsExtractor context, CallbackInfo ci) {
23
        AbstractSelectionList<?> self = (AbstractSelectionList<?>) (Object) this;
24
        BetterButtons.pushScissorContext(self.getX(), self.getY(), self.getRight(), self.getBottom());
25
    }
26
27
    @Inject(
28
            method = "extractWidgetRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
29
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;disableScissor()V")
30
    )
31
    private void combatant$popScissor(GuiGraphicsExtractor context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) {
32
        BetterButtons.popScissorContext();
33
    }
34
}
35
36
37
38
39
AbstractSliderButtonMixinsrc/main/java/combatant/client/mixins/AbstractSliderButtonMixin.javaJava · 47 lines · 2.0 KB
@Mixin(AbstractSliderButton.class)
AbstractSliderButtonMixin.javaJava · 47 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.AbstractSliderButton;
14
import net.minecraft.client.gui.components.AbstractWidget;
15
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
21
import combatant.client.mixins.accessors.SliderWidgetAccessor;
22
23
@Mixin(AbstractSliderButton.class)
24
public abstract class AbstractSliderButtonMixin {
25
26
    @Inject(method = "extractWidgetRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
27
    private void combatant$renderWidget(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
28
        BetterButtons buttons = BetterButtons.get();
29
        if (buttons == null || !buttons.useUiButtons()) return;
30
        Minecraft mc = Minecraft.getInstance();
31
        if (mc != null && ClientScreen.current() instanceof MerchantScreen) return;
32
        AbstractSliderButton self = (AbstractSliderButton) (Object) this;
33
        AbstractWidget widget = self;
34
35
        boolean hovered = widget.isMouseOver(mouseX, mouseY);
36
        boolean dragging = ((SliderWidgetAccessor) self).combatant$isDragging();
37
        float hover = BetterButtons.updateHover(widget, hovered || dragging, mouseX, mouseY);
38
39
        double value = ((SliderWidgetAccessor) self).combatant$getValue();
40
        BetterButtons.enqueueSlider(widget, (float) value, dragging, hover);
41
        ci.cancel();
42
    }
43
}
44
45
46
47
AbstractWidgetSoundMixinsrc/main/java/combatant/client/mixins/AbstractWidgetSoundMixin.javaJava · 33 lines · 1.3 KB
@Mixin(AbstractWidget.class)
AbstractWidgetSoundMixin.javaJava · 33 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.features.gui.clickgui.sound.GuiSound;
11
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
12
import combatant.client.runtime.RuntimeGate;
13
import combatant.client.util.sound.SoundSystem;
14
import net.minecraft.client.gui.components.AbstractWidget;
15
import net.minecraft.client.sounds.SoundManager;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
21
/** Replaces vanilla widget press feedback while Combatant runtime features are active. */
22
@Mixin(AbstractWidget.class)
23
public abstract class AbstractWidgetSoundMixin {
24
    @Inject(method = "playDownSound", at = @At("HEAD"), cancellable = true)
25
    private void combatant$replaceVanillaButtonSound(SoundManager soundManager, CallbackInfo ci) {
26
        if (!RuntimeGate.canRunModules()) return;
27
        if (!BetterButtons.get().useCustomButtonSounds()) return;
28
        if (!SoundSystem.get().isReady()) return;
29
        GuiSound.BUTTON.feedback(0.65);
30
        ci.cancel();
31
    }
32
}
33
AtmosphericFogEnvironmentMixinsrc/main/java/combatant/client/mixins/AtmosphericFogEnvironmentMixin.javaJava · 58 lines · 2.2 KB
@Mixin(value = AtmosphericFogEnvironment.class, priority = 1200)priority 1200
AtmosphericFogEnvironmentMixin.javaJava · 58 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.multiplayer.ClientLevel;
13
import net.minecraft.client.renderer.fog.FogData;
14
import net.minecraft.client.renderer.fog.environment.AtmosphericFogEnvironment;
15
import net.minecraft.world.level.Level;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.features.module.Modules;
21
import combatant.client.features.module.modules.visuals.WorldTweaks;
22
23
@Mixin(value = AtmosphericFogEnvironment.class, priority = 1200)
24
public class AtmosphericFogEnvironmentMixin {
25
26
    @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
27
    private void combatant$noDimensionFog(FogData data,
28
                                          Camera camera,
29
                                          ClientLevel world,
30
                                          float viewDistance,
31
                                          DeltaTracker tickCounter,
32
                                          CallbackInfo ci) {
33
        WorldTweaks module = Modules.get(WorldTweaks.class);
34
        if (module == null || !module.isFogControlEnabled()) return;
35
        if (module.isFogModifyEnabled()) {
36
            module.applyFogOverride(data);
37
            ci.cancel();
38
            return;
39
        }
40
        if (world == null) return;
41
42
        boolean disable =
43
                (world.dimension() == Level.OVERWORLD && module.disableOverworldFog())
44
                        || (world.dimension() == Level.NETHER && module.disableNetherFog())
45
                        || (world.dimension() == Level.END && module.disableEndFog());
46
47
        if (!disable) return;
48
49
        float far = Math.max(viewDistance, 16.0f);
50
        data.environmentalStart = far;
51
        data.environmentalEnd = far;
52
        data.skyEnd = far;
53
        data.cloudEnd = far;
54
        ci.cancel();
55
    }
56
}
57
58
AvatarRendererMixinsrc/main/java/combatant/client/mixins/AvatarRendererMixin.javaJava · 55 lines · 2.3 KB
@Mixin(AvatarRenderer.class)
AvatarRendererMixin.javaJava · 55 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.features.module.Modules;
11
import combatant.client.features.module.modules.visuals.ViewModel;
12
import combatant.client.features.playeranimator.PlayerAnimator;
13
import combatant.client.features.playeranimator.PlayerRigRenderState;
14
import combatant.client.render.helpers.TickDelta;
15
import net.minecraft.client.player.AbstractClientPlayer;
16
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
17
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
18
import net.minecraft.world.entity.Avatar;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23
24
/**
25
 * Builds the rig only after AvatarRenderer has populated the complete Humanoid/Avatar render state.
26
 * Doing this from LivingEntityRenderer.extractRenderState is too early: swim, arm-pose and flight
27
 * fields are filled by AvatarRenderer only after its super call returns.
28
 */
29
@Mixin(AvatarRenderer.class)
30
public abstract class AvatarRendererMixin {
31
    @Inject(
32
            method = "extractRenderState(Lnet/minecraft/world/entity/Avatar;Lnet/minecraft/client/renderer/entity/state/AvatarRenderState;F)V",
33
            at = @At("TAIL")
34
    )
35
    private void combatant$extractPlayerRig(Avatar entity, AvatarRenderState state,
36
                                            float tickProgress, CallbackInfo ci) {
37
        if (!(entity instanceof AbstractClientPlayer player) || !(state instanceof PlayerRigRenderState rigState)) {
38
            return;
39
        }
40
        ViewModel viewModel = Modules.get(ViewModel.class);
41
        if (viewModel == null || !viewModel.isPlayerRigActive()) {
42
            rigState.combatant$setPlayerRig(null);
43
            return;
44
        }
45
        rigState.combatant$setPlayerRig(PlayerAnimator.animate(
46
                player,
47
                state,
48
                tickProgress,
49
                TickDelta.frameDeltaSeconds(),
50
                viewModel.playerRigStyle(),
51
                viewModel.playerRigStrength()
52
        ));
53
    }
54
}
55
BatchingRenderCommandQueueMixinsrc/main/java/combatant/client/mixins/BatchingRenderCommandQueueMixin.javaJava · 74 lines · 2.7 KB
@Mixin(SubmitNodeCollection.class)
BatchingRenderCommandQueueMixin.javaJava · 74 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.SubmitNodeCollection;
11
import net.minecraft.util.Mth;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Unique;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.ModifyVariable;
16
import combatant.client.render.ViewObstructionFadeContext;
17
import combatant.client.render.engine.msaa.MsaaWorldTarget;
18
19
import java.util.Arrays;
20
21
@Mixin(SubmitNodeCollection.class)
22
public abstract class BatchingRenderCommandQueueMixin {
23
    @Unique
24
    private static final int COMBATANT_VIEW_FADE_DITHER_MARK = 0x00010001;
25
    @Unique
26
    private static final int COMBATANT_VIEW_FADE_A2C_MARK = 0x00010100;
27
28
    @Unique
29
    private static int combatant$markViewObstructionFade(int argb, float alpha, boolean msaaActive) {
30
        int rgb = (argb & 0x00FEFEFE) | (msaaActive ? COMBATANT_VIEW_FADE_A2C_MARK : COMBATANT_VIEW_FADE_DITHER_MARK);
31
        int alphaByte = Math.round(255.0f * Mth.clamp(alpha, 0.0f, 1.0f));
32
        return rgb | ((alphaByte & 0xFF) << 24);
33
    }
34
35
    @Unique
36
    private static boolean combatant$shouldApplyViewObstructionFade() {
37
        return ViewObstructionFadeContext.isActive() && ViewObstructionFadeContext.alpha() < 0.99f;
38
    }
39
40
    @Unique
41
    private static int combatant$applyFadeToArgb(int color) {
42
        int baseColor = color == -1 ? 0xFFFFFFFF : ((color & 0x00FFFFFF) | 0xFF000000);
43
        return combatant$markViewObstructionFade(baseColor, ViewObstructionFadeContext.alpha(), MsaaWorldTarget.isActive());
44
    }
45
46
    @ModifyVariable(method = "submitModel", at = @At("HEAD"), argsOnly = true, index = 7)
47
    private int combatant$applyViewObstructionFadeAlpha(int tintedColor) {
48
        if (!combatant$shouldApplyViewObstructionFade()) {
49
            return tintedColor;
50
        }
51
        return combatant$applyFadeToArgb(tintedColor);
52
    }
53
54
    @ModifyVariable(method = "submitItem", at = @At("HEAD"), argsOnly = true, index = 6)
55
    private int[] combatant$applyViewObstructionFadeAlphaToItemTints(int[] tints) {
56
        if (!combatant$shouldApplyViewObstructionFade()) {
57
            return tints;
58
        }
59
60
        int sentinel = combatant$applyFadeToArgb(-1);
61
        if (tints == null || tints.length == 0) {
62
            return new int[]{sentinel};
63
        }
64
65
        int[] faded = Arrays.copyOf(tints, tints.length);
66
        faded[0] = combatant$applyFadeToArgb(faded[0]);
67
        for (int i = 1; i < faded.length; i++) {
68
            faded[i] = combatant$applyFadeToArgb(faded[i]);
69
        }
70
        return faded;
71
    }
72
73
}
74
BeaconRendererMixinsrc/main/java/combatant/client/mixins/BeaconRendererMixin.javaJava · 42 lines · 1.6 KB
@Mixin(value = BeaconRenderer.class, priority = 1200)priority 1200
BeaconRendererMixin.javaJava · 42 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import combatant.client.features.module.Modules;
12
import combatant.client.features.module.modules.visuals.NoRender;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
15
import net.minecraft.client.renderer.blockentity.state.BeaconRenderState;
16
import net.minecraft.client.renderer.state.level.CameraRenderState;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
@Mixin(value = BeaconRenderer.class, priority = 1200)
23
public abstract class BeaconRendererMixin {
24
    @Inject(
25
            method = "submit(Lnet/minecraft/client/renderer/blockentity/state/BeaconRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
26
            at = @At("HEAD"),
27
            cancellable = true
28
    )
29
    private void combatant$noRenderBeaconBeam(
30
            BeaconRenderState state,
31
            PoseStack poseStack,
32
            SubmitNodeCollector collector,
33
            CameraRenderState cameraState,
34
            CallbackInfo ci
35
    ) {
36
        NoRender noRender = Modules.get(NoRender.class);
37
        if (noRender != null && noRender.offEntity("beacon_beams")) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
BiomeMixinsrc/main/java/combatant/client/mixins/BiomeMixin.javaJava · 45 lines · 1.6 KB
@Mixin(Biome.class)
ModifiesBiome
BiomeMixin.javaJava · 45 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
package combatant.client.mixins;
8
9
import combatant.client.mixininterface.IBiome;
10
import combatant.client.mixins.accessors.BiomeClimateSettingsAccessor;
11
import net.minecraft.world.attribute.EnvironmentAttributeMap;
12
import net.minecraft.world.level.biome.Biome;
13
import net.minecraft.world.level.biome.BiomeGenerationSettings;
14
import net.minecraft.world.level.biome.BiomeSpecialEffects;
15
import net.minecraft.world.level.biome.MobSpawnSettings;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Coerce;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
23
@Mixin(Biome.class)
24
public abstract class BiomeMixin implements IBiome {
25
    @Unique
26
    private float combatant$downfall;
27
28
    @Inject(method = "<init>", at = @At("RETURN"))
29
    private void combatant$captureDownfall(
30
            @Coerce Object climateSettings,
31
            EnvironmentAttributeMap attributes,
32
            BiomeSpecialEffects specialEffects,
33
            BiomeGenerationSettings generationSettings,
34
            MobSpawnSettings mobSettings,
35
            CallbackInfo ci
36
    ) {
37
        combatant$downfall = ((BiomeClimateSettingsAccessor) climateSettings).combatant$getDownfall();
38
    }
39
40
    @Override
41
    public float combatant$getDownfall() {
42
        return combatant$downfall;
43
    }
44
}
45
BlockCollisionSpliteratorMixinsrc/main/java/combatant/client/mixins/BlockCollisionSpliteratorMixin.javaJava · 42 lines · 1.5 KB
@Mixin(value = BlockCollisions.class, priority = 800)priority 800
BlockCollisionSpliteratorMixin.javaJava · 42 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 * Portions derived from ThunderHack Recode, copyright (c) 2023-2024 Pan4ur & 06ED.
5
 * Upstream: https://github.com/Pan4ur/ThunderHack-Recode
6
 *
7
 * Licensed under the GNU General Public License v3.0.
8
 */
9
10
package combatant.client.mixins;
11
12
import net.minecraft.core.BlockPos;
13
import net.minecraft.world.level.BlockCollisions;
14
import net.minecraft.world.level.BlockGetter;
15
import net.minecraft.world.level.block.state.BlockState;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Redirect;
19
import combatant.client.events.Events;
20
import combatant.client.events.impl.EventCollision;
21
22
@Mixin(value = BlockCollisions.class, priority = 800)
23
public abstract class BlockCollisionSpliteratorMixin {
24
25
    @Redirect(
26
            method = "computeNext",
27
            at = @At(
28
                    value = "INVOKE",
29
                    target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"
30
            )
31
    )
32
    private BlockState combatant$collisionHook(BlockGetter instance, BlockPos blockPos) {
33
        BlockState state = instance.getBlockState(blockPos);
34
        if (!Events.BUS.hasListeners(EventCollision.class)) {
35
            return state;
36
        }
37
        EventCollision event = new EventCollision(state, blockPos);
38
        Events.BUS.post(event);
39
        return event.getState();
40
    }
41
}
42
BlockEntityRenderDispatcherTemporalMixinsrc/main/java/combatant/client/mixins/BlockEntityRenderDispatcherTemporalMixin.javaJava · 38 lines · 1.9 KB
@Mixin(BlockEntityRenderDispatcher.class)
BlockEntityRenderDispatcherTemporalMixin.javaJava · 38 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.mixininterface.ITemporalMotionRenderState;
11
import combatant.client.render.engine.core.CombatantRenderSystem;
12
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
13
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
14
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
15
import net.minecraft.world.level.block.entity.BlockEntity;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
20
21
@Mixin(BlockEntityRenderDispatcher.class)
22
public abstract class BlockEntityRenderDispatcherTemporalMixin {
23
    @Inject(
24
            method = "tryExtractRenderState(Lnet/minecraft/world/level/block/entity/BlockEntity;FLnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;Z)Lnet/minecraft/client/renderer/blockentity/state/BlockEntityRenderState;",
25
            at = @At("RETURN")
26
    )
27
    private void combatant$captureTemporalMotion(BlockEntity blockEntity,
28
                                                  float tickProgress,
29
                                                  ModelFeatureRenderer.CrumblingOverlay crumblingOverlay,
30
                                                  boolean renderBoundingBox,
31
                                                  CallbackInfoReturnable<BlockEntityRenderState> cir) {
32
        BlockEntityRenderState state = cir.getReturnValue();
33
        if (!(state instanceof ITemporalMotionRenderState temporalState)) return;
34
        temporalState.combatant$setTemporalMotionState(
35
                CombatantRenderSystem.deferredWorld().captureBlockEntityMotion(blockEntity, state));
36
    }
37
}
38
BlockEntityRenderStateTemporalMixinsrc/main/java/combatant/client/mixins/BlockEntityRenderStateTemporalMixin.javaJava · 31 lines · 1.0 KB
@Mixin(BlockEntityRenderState.class)
BlockEntityRenderStateTemporalMixin.javaJava · 31 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.mixininterface.ITemporalMotionRenderState;
11
import combatant.client.render.engine.deferred.DeferredMotionState;
12
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
13
import org.jetbrains.annotations.Nullable;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.Unique;
16
17
@Mixin(BlockEntityRenderState.class)
18
public class BlockEntityRenderStateTemporalMixin implements ITemporalMotionRenderState {
19
    @Unique private @Nullable DeferredMotionState combatant$temporalMotionState;
20
21
    @Override
22
    public @Nullable DeferredMotionState combatant$getTemporalMotionState() {
23
        return combatant$temporalMotionState;
24
    }
25
26
    @Override
27
    public void combatant$setTemporalMotionState(@Nullable DeferredMotionState state) {
28
        combatant$temporalMotionState = state;
29
    }
30
}
31
BlockMixinsrc/main/java/combatant/client/mixins/BlockMixin.javaJava · 44 lines · 1.4 KB
@Mixin(Block.class)
ModifiesBlock
BlockMixin.javaJava · 44 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.world.level.block.Block;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Inject;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15
import combatant.client.util.player.EnvironmentMovementController;
16
17
@Mixin(Block.class)
18
public abstract class BlockMixin {
19
20
    @Inject(
21
            method = "getFriction",
22
            at = @At("HEAD"),
23
            cancellable = true
24
    )
25
    private void nostun$overrideSlipperiness(CallbackInfoReturnable<Float> cir) {
26
        Float override = EnvironmentMovementController.getSlipperinessOverride((Block) (Object) this);
27
        if (override != null) {
28
            cir.setReturnValue(override);
29
        }
30
    }
31
32
    @Inject(
33
            method = "getSpeedFactor",
34
            at = @At("HEAD"),
35
            cancellable = true
36
    )
37
    private void nostun$overrideVelocityMultiplier(CallbackInfoReturnable<Float> cir) {
38
        Float override = EnvironmentMovementController.getVelocityMultiplierOverride((Block) (Object) this);
39
        if (override != null) {
40
            cir.setReturnValue(override);
41
        }
42
    }
43
}
44
BossHealthOverlayMixinsrc/main/java/combatant/client/mixins/BossHealthOverlayMixin.javaJava · 81 lines · 2.5 KB
@Mixin(BossHealthOverlay.class)
BossHealthOverlayMixin.javaJava · 81 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.events.Events;
11
import combatant.client.events.impl.CombatProtocolBossbarEvent;
12
import combatant.client.mixins.accessors.BossHealthOverlayAccessor;
13
import net.minecraft.client.gui.GuiGraphicsExtractor;
14
import net.minecraft.client.gui.components.BossHealthOverlay;
15
import net.minecraft.client.gui.components.LerpingBossEvent;
16
import net.minecraft.network.chat.Component;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
import java.util.ArrayList;
23
import java.util.List;
24
25
@Mixin(BossHealthOverlay.class)
26
public class BossHealthOverlayMixin {
27
28
    @Inject(method = "extractRenderState", at = @At("HEAD"))
29
    private void onRender(GuiGraphicsExtractor ctx, CallbackInfo ci) {
30
        if (Events.BUS.hasListeners(CombatProtocolBossbarEvent.class)) {
31
            List<String> names = new ArrayList<>();
32
            for (LerpingBossEvent bar : ((BossHealthOverlayAccessor) this).getBars().values()) {
33
                if (bar == null) continue;
34
                Component name = bar.getName();
35
                if (name != null && !name.getString().isBlank()) {
36
                    names.add(name.getString());
37
                }
38
            }
39
            if (!names.isEmpty()) {
40
                Events.BUS.post(new CombatProtocolBossbarEvent(names));
41
            }
42
        }
43
44
        // PvP bossbar detection disabled: bossbar no longer reliable.
45
        /*
46
        BossBarHud hud = (BossBarHud) (Object) this;
47
48
        Map<UUID, ClientBossBar> bars =
49
                ((BossHealthOverlayAccessor) hud).getBars();
50
51
        boolean pvpActive = false;
52
53
        // проверяем только боссбары
54
        for (ClientBossBar bar : bars.values()) {
55
56
            String name = bar.getName().getString();
57
58
            if (name.startsWith("Режим PVP -")) {
59
                pvpActive = true;
60
                break;
61
            }
62
        }
63
64
        // === только тут меняем состояние PvP ===
65
66
        if (pvpActive && !CooldownsState.MANAGER.isInPvp()) {
67
            CooldownsState.MANAGER.enterPvp();
68
        }
69
70
        if (!pvpActive && CooldownsState.MANAGER.isInPvp()) {
71
            CooldownsState.MANAGER.exitPvp();
72
        }
73
        */
74
    }
75
}
76
77
78
79
80
81
BufferManagerDefaultBufferManagerMixinsrc/main/java/combatant/client/mixins/BufferManagerDefaultBufferManagerMixin.javaJava · 42 lines · 1.6 KB
@Mixin(targets = "com.mojang.blaze3d.opengl.DirectStateAccess$Emulated")
BufferManagerDefaultBufferManagerMixin.javaJava · 42 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.injection.At;
12
import org.spongepowered.asm.mixin.injection.Inject;
13
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14
import combatant.client.render.engine.core.CombatantRenderSystem;
15
16
@Mixin(targets = "com.mojang.blaze3d.opengl.DirectStateAccess$Emulated")
17
public abstract class BufferManagerDefaultBufferManagerMixin {
18
    @Inject(method = "bindFrameBufferTextures", at = @At("HEAD"), cancellable = true)
19
    private void combatant$setupFramebuffer(int framebuffer,
20
                                            int[] colorAttachments,
21
                                            int[] colorMipLevels,
22
                                            int depthAttachment,
23
                                            int depthMipLevel,
24
                                            int bindTarget,
25
                                            CallbackInfo ci) {
26
        if (colorAttachments == null || colorAttachments.length != 1) {
27
            return;
28
        }
29
30
        int colorAttachment = colorAttachments[0];
31
        int mipLevel = colorMipLevels != null && colorMipLevels.length > 0 ? colorMipLevels[0] : depthMipLevel;
32
        if (CombatantRenderSystem.rhi().msaa().setupFramebuffer(framebuffer, colorAttachment, depthAttachment, mipLevel, bindTarget)) {
33
            ci.cancel();
34
        }
35
    }
36
}
37
38
39
40
41
42
ButtonWidgetTextMixinsrc/main/java/combatant/client/mixins/ButtonWidgetTextMixin.javaJava · 39 lines · 1.7 KB
@Mixin(Button.Plain.class)
ButtonWidgetTextMixin.javaJava · 39 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.AbstractWidget;
14
import net.minecraft.client.gui.components.Button;
15
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
21
22
@Mixin(Button.Plain.class)
23
public abstract class ButtonWidgetTextMixin {
24
25
    @Inject(method = "extractContents(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
26
    private void combatant$drawIcon(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
27
        BetterButtons buttons = BetterButtons.get();
28
        if (buttons == null || !buttons.useUiButtons()) return;
29
        Minecraft mc = Minecraft.getInstance();
30
        if (mc != null && ClientScreen.current() instanceof MerchantScreen) return;
31
        AbstractWidget widget = (AbstractWidget) (Object) this;
32
        boolean hovered = widget.isMouseOver(mouseX, mouseY);
33
        float hover = BetterButtons.updateHover(widget, hovered, mouseX, mouseY);
34
        BetterButtons.enqueueButton(widget, widget.getMessage(), hover, widget.isActive(), widget.isFocused());
35
        ci.cancel();
36
    }
37
}
38
39
CameraMixinsrc/main/java/combatant/client/mixins/CameraMixin.javaJava · 210 lines · 7.6 KB
@Mixin(Camera.class)
ModifiesCamera
CameraMixin.javaJava · 210 lines · 7.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.CameraType;
12
import net.minecraft.client.DeltaTracker;
13
import net.minecraft.client.Minecraft;
14
import net.minecraft.util.Mth;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.level.Level;
17
import net.minecraft.client.renderer.state.level.CameraRenderState;
18
import net.minecraft.world.level.material.FogType;
19
import net.minecraft.world.phys.Vec3;
20
import org.joml.Matrix4f;
21
import org.joml.Matrix4fc;
22
import org.spongepowered.asm.mixin.Mixin;
23
import org.spongepowered.asm.mixin.Shadow;
24
import org.spongepowered.asm.mixin.Unique;
25
import org.spongepowered.asm.mixin.gen.Invoker;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30
import combatant.client.features.module.Modules;
31
import combatant.client.features.module.modules.visuals.CameraClip;
32
import combatant.client.features.module.modules.visuals.FovControl;
33
import combatant.client.features.module.modules.visuals.Freecam;
34
import combatant.client.features.module.modules.visuals.Zoom;
35
import combatant.client.util.render.CameraOcclusionPolicy;
36
37
@Mixin(Camera.class)
38
public abstract class CameraMixin {
39
40
41
    @Shadow
42
    private boolean initialized;
43
    @Shadow
44
    private Level level;
45
    @Shadow
46
    private Entity entity;
47
48
    @Unique
49
    private static float combatant$getGameFov() {
50
        Minecraft mc = Minecraft.getInstance();
51
        if (mc == null) return 70.0f;
52
        return mc.options.fov().get();
53
    }
54
55
    @Unique
56
    private static float combatant$getFovEffectScale() {
57
        Minecraft mc = Minecraft.getInstance();
58
        if (mc == null) return 1.0f;
59
        return mc.options.fovEffectScale().get().floatValue();
60
    }
61
62
    @Shadow
63
    protected abstract void move(float surge, float heave, float sway);
64
65
    @Inject(method = "getMaxZoom(F)F", at = @At("HEAD"), cancellable = true)
66
    private void combatant$disableCameraCollision(float desiredDistance, CallbackInfoReturnable<Float> cir) {
67
        CameraClip mod = Modules.get(CameraClip.class);
68
        if (mod != null && mod.isEnabled() && isThirdPerson()) {
69
            // Skip collision shortening and apply distance multiplier
70
            float dist = desiredDistance * mod.distanceMultiplier();
71
            cir.setReturnValue(dist);
72
        }
73
    }
74
75
    @Inject(method = "update", at = @At("TAIL"))
76
    private void combatant$applyCameraOffsets(DeltaTracker tickCounter, CallbackInfo ci) {
77
        CameraClip mod = Modules.get(CameraClip.class);
78
        if (mod == null || !mod.isEnabled() || !isThirdPerson()) return;
79
80
        float back = mod.backOffset();
81
        float up = mod.upOffset();
82
        float right = mod.rightOffset();
83
84
        if (back != 0.0f || up != 0.0f || right != 0.0f) {
85
            // move uses (surge, heave, sway); negative surge moves backward. Vanilla has
86
            // already prepared cullFrustum before this TAIL injection, so moving the camera
87
            // without rebuilding it leaves section frustum tests anchored at the old position.
88
            move(-back, up, right);
89
            Vec3 cameraPos = ((Camera) (Object) this).position();
90
            combatant$prepareCullFrustum(
91
                    getViewRotationMatrix(new Matrix4f()),
92
                    combatant$createProjectionMatrixForCulling(),
93
                    cameraPos
94
            );
95
        }
96
    }
97
98
    @Inject(method = "calculateFov", at = @At("RETURN"), cancellable = true)
99
    private void combatant$adjustCalculatedFov(float tickDelta, CallbackInfoReturnable<Float> cir) {
100
        cir.setReturnValue(combatant$adjustFovValue(cir.getReturnValue()));
101
    }
102
103
    @Unique
104
    private float combatant$adjustFovValue(float fov) {
105
        FovControl module = Modules.get(FovControl.class);
106
        Zoom zoom = Modules.get(Zoom.class);
107
108
        boolean hasFovControl = module != null && module.isEnabled();
109
        boolean hasZoom = zoom != null && zoom.isEnabled() && zoom.shouldApplyZoom();
110
        if (!hasFovControl && !hasZoom) return fov;
111
112
        if (hasFovControl && module.useCustomFov()) {
113
            float base = combatant$getGameFov();
114
            float custom = module.getCustomFov();
115
            if (base > 0.01f) {
116
                fov = fov * (custom / base);
117
            } else {
118
                fov = custom;
119
            }
120
        }
121
122
        if (hasFovControl && module.disableFluidFov()) {
123
            FogType type = ((Camera) (Object) this).getFluidInCamera();
124
            if (type == FogType.WATER || type == FogType.LAVA) {
125
                float effectScale = combatant$getFovEffectScale();
126
                float factor = Mth.lerp(effectScale, 1.0f, 0.85714287f);
127
                if (factor > 0.0001f) {
128
                    fov /= factor;
129
                }
130
            }
131
        }
132
133
        if (hasZoom) {
134
            float divisor = zoom.getZoomDivisor();
135
            if (divisor > 1.0f) {
136
                fov /= divisor;
137
            }
138
        }
139
140
        return fov;
141
    }
142
143
    @Unique
144
    private boolean isThirdPerson() {
145
        Minecraft mc = Minecraft.getInstance();
146
        if (mc == null || mc.options == null) return false;
147
        CameraType p = mc.options.getCameraType();
148
        return p == CameraType.THIRD_PERSON_BACK || p == CameraType.THIRD_PERSON_FRONT;
149
    }
150
151
    @Shadow
152
    protected abstract void setRotation(float yaw, float pitch);
153
154
    @Shadow
155
    protected abstract void setPosition(Vec3 pos);
156
157
    @Shadow
158
    public abstract Matrix4f getViewRotationMatrix(Matrix4f matrix);
159
160
    @Invoker("createProjectionMatrixForCulling")
161
    protected abstract Matrix4f combatant$createProjectionMatrixForCulling();
162
163
    @Invoker("prepareCullFrustum")
164
    protected abstract void combatant$prepareCullFrustum(Matrix4fc viewMatrix, Matrix4f projectionMatrix, Vec3 cameraPos);
165
166
    @Inject(method = "update", at = @At("TAIL"))
167
    private void freecam$override(
168
            DeltaTracker tickCounter,
169
            CallbackInfo ci
170
    ) {
171
        Freecam fc = Modules.get(Freecam.class);
172
        if (fc == null || !fc.isEnabled() || fc.camEntity == null) return;
173
174
        this.initialized = true;
175
        if (Minecraft.getInstance().level != null) {
176
            this.level = Minecraft.getInstance().level;
177
        }
178
        this.entity = fc.camEntity;
179
180
        this.setRotation(fc.camYaw, fc.camPitch);
181
182
        float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
183
        Vec3 p = fc.getCameraPos(tickDelta);
184
        fc.syncCameraEntity(fc.camPos, fc.camPosPrev);
185
186
        this.setPosition(p);
187
        this.combatant$prepareCullFrustum(this.getViewRotationMatrix(new Matrix4f()), this.combatant$createProjectionMatrixForCulling(), p);
188
    }
189
190
    @Inject(method = "extractRenderState", at = @At("TAIL"))
191
    private void combatant$freecamExtractRenderState(CameraRenderState renderState, float tickDelta, CallbackInfo ci) {
192
        Freecam fc = Modules.get(Freecam.class);
193
        if (fc == null || !fc.isEnabled() || fc.camEntity == null) return;
194
195
        renderState.smartCull = false;
196
    }
197
198
    @Inject(method = "extractRenderState", at = @At("TAIL"))
199
    private void combatant$disableInsideBlockSectionOcclusion(CameraRenderState renderState, float tickDelta, CallbackInfo ci) {
200
        if (!renderState.smartCull) return;
201
        if (CameraOcclusionPolicy.shouldDisableSectionOcclusion((Camera) (Object) this)) {
202
            renderState.smartCull = false;
203
        }
204
    }
205
}
206
207
208
209
210
ChatComponentMixinsrc/main/java/combatant/client/mixins/ChatComponentMixin.javaJava · 91 lines · 4.1 KB
@Mixin(ChatComponent.class)
ChatComponentMixin.javaJava · 91 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.Font;
11
import net.minecraft.client.gui.GuiGraphicsExtractor;
12
import net.minecraft.client.gui.components.ChatComponent;
13
import net.minecraft.client.gui.components.ChatComponent.DisplayMode;
14
import net.minecraft.client.multiplayer.chat.GuiMessageSource;
15
import net.minecraft.client.multiplayer.chat.GuiMessageTag;
16
import net.minecraft.client.multiplayer.chat.GuiMessage;
17
import net.minecraft.network.chat.Component;
18
import net.minecraft.network.chat.MessageSignature;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23
import combatant.client.features.command.CommandOutput;
24
import combatant.client.features.gui.chat.BetterChatStoreManager;
25
import combatant.client.features.gui.hud.draggable.impl.BetterChat;
26
import combatant.client.features.module.Modules;
27
import combatant.client.features.module.modules.misc.MessageFilter;
28
import combatant.client.runtime.RuntimeGate;
29
30
@Mixin(ChatComponent.class)
31
public class ChatComponentMixin {
32
33
    @Inject(
34
            method = "addMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageSource;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V",
35
            at = @At("HEAD"),
36
            cancellable = true
37
    )
38
    private void combatant$filterChatFull(Component message,
39
                                          MessageSignature signatureData,
40
                                          GuiMessageSource source,
41
                                          GuiMessageTag indicator,
42
                                          CallbackInfo ci) {
43
        if (!RuntimeGate.canRunHud()) return;
44
        MessageFilter messageFilter = Modules.get(MessageFilter.class);
45
        if (messageFilter != null && messageFilter.shouldHideChat(message)) {
46
            ci.cancel();
47
            return;
48
        }
49
        if (!CommandOutput.isCombatantMessage(message)) {
50
            boolean accepted = BetterChatStoreManager.addMessage(message);
51
            if (!accepted && BetterChat.isActive()) {
52
                ci.cancel();
53
            }
54
        }
55
    }
56
57
    @Inject(method = "logChatMessage(Lnet/minecraft/client/multiplayer/chat/GuiMessage;)V", at = @At("HEAD"), cancellable = true)
58
    private void combatant$commands$suppressClientLog(GuiMessage message, CallbackInfo ci) {
59
        if (message != null && CommandOutput.isCombatantMessage(message.content())) {
60
            ci.cancel();
61
        }
62
    }
63
64
    @Inject(method = "clearMessages(Z)V", at = @At("TAIL"))
65
    private void combatant$betterChat$clear(boolean clearHistory, CallbackInfo ci) {
66
        if (!RuntimeGate.canRunHud()) return;
67
        if (!BetterChat.isActive()) return;
68
        // Never wipe BetterChat store on vanilla clear; just persist to disk.
69
        BetterChatStoreManager.flushActive();
70
    }
71
72
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/gui/Font;IIILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;Z)V",
73
            at = @At("HEAD"), cancellable = true)
74
    private void combatant$betterChat$hideVanilla(GuiGraphicsExtractor context,
75
                                                  Font textRenderer,
76
                                                  int currentTick,
77
                                                  int mouseX,
78
                                                  int mouseY,
79
                                                  DisplayMode displayMode,
80
                                                  boolean inChat,
81
                                                  CallbackInfo ci) {
82
        if (!RuntimeGate.canRunHud()) return;
83
        if (!BetterChat.isActive()) return;
84
        BetterChat cfg = BetterChat.get();
85
        if (cfg != null && cfg.hideVanilla()) {
86
            ci.cancel();
87
        }
88
    }
89
}
90
91
ChatScreenMixinsrc/main/java/combatant/client/mixins/ChatScreenMixin.javaJava · 103 lines · 4.8 KB
@Mixin(ChatScreen.class)
ModifiesChatScreen
ChatScreenMixin.javaJava · 103 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.ActiveTextCollector;
11
import net.minecraft.client.gui.GuiGraphicsExtractor;
12
import net.minecraft.client.gui.components.ChatComponent;
13
import net.minecraft.client.gui.components.ChatComponent.DisplayMode;
14
import net.minecraft.client.gui.components.CommandSuggestions;
15
import net.minecraft.client.gui.screens.ChatScreen;
16
import net.minecraft.client.input.KeyEvent;
17
import org.spongepowered.asm.mixin.Mixin;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
24
import combatant.client.features.command.CommandManager;
25
import combatant.client.features.gui.chat.BetterChatRenderer;
26
import combatant.client.features.gui.hud.draggable.impl.BetterChat;
27
import combatant.client.mixins.accessors.ChatScreenSuggestorAccessor;
28
import combatant.client.runtime.RuntimeGate;
29
30
@Mixin(ChatScreen.class)
31
public class ChatScreenMixin {
32
33
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
34
    private void combatant$betterChat$render(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
35
        if (!RuntimeGate.canRunHud()) return;
36
        if (BetterChat.isActive()) {
37
            BetterChat cfg = BetterChat.get();
38
            if (cfg != null && cfg.hideVanilla()) {
39
                // Stash suggestion context; BetterChatRenderer will draw it in correct Z-order.
40
                BetterChatRenderer.setSuggestionContext((ChatScreen) (Object) this, context, mouseX, mouseY);
41
                ci.cancel();
42
            }
43
        }
44
    }
45
46
    @Redirect(
47
            method = "mouseClicked(Lnet/minecraft/client/input/MouseButtonEvent;Z)Z",
48
            at = @At(
49
                    value = "INVOKE",
50
                    target = "Lnet/minecraft/client/gui/components/ChatComponent;captureClickableText(Lnet/minecraft/client/gui/ActiveTextCollector;IILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;)V"
51
            )
52
    )
53
    private void combatant$betterChat$disableVanillaChatClickHitbox(ChatComponent chatHud,
54
                                                                    ActiveTextCollector textConsumer,
55
                                                                    int windowHeight,
56
                                                                    int currentTick,
57
                                                                    DisplayMode displayMode) {
58
        if (combatant$betterChat$shouldHideVanillaChat()) {
59
            return;
60
        }
61
        chatHud.captureClickableText(textConsumer, windowHeight, currentTick, displayMode);
62
    }
63
64
    @Inject(method = "mouseScrolled(DDDD)Z", at = @At("HEAD"), cancellable = true)
65
    private void combatant$betterChat$disableVanillaChatScroll(double mouseX,
66
                                                               double mouseY,
67
                                                               double horizontalAmount,
68
                                                               double verticalAmount,
69
                                                               CallbackInfoReturnable<Boolean> cir) {
70
        if (combatant$betterChat$shouldHideVanillaChat()) {
71
            cir.setReturnValue(true);
72
        }
73
    }
74
75
    @Inject(method = "keyPressed(Lnet/minecraft/client/input/KeyEvent;)Z", at = @At("HEAD"))
76
    private void combatant$betterChat$allowEscape(KeyEvent input, CallbackInfoReturnable<Boolean> cir) {
77
        if (!RuntimeGate.canRunHud()) return;
78
        if (!BetterChat.isActive()) return;
79
        if (!input.isEscape()) return;
80
        CommandSuggestions suggestor = ((ChatScreenSuggestorAccessor) this).getCombatant$suggestor();
81
        if (suggestor != null) {
82
            suggestor.setAllowSuggestions(false);
83
            suggestor.hide();
84
        }
85
    }
86
87
    @Inject(method = "handleChatInput(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true, require = 0)
88
    private void combatant$commands$sendMessage(String message, boolean addToHistory, CallbackInfo ci) {
89
        if (!RuntimeGate.canRunClientLogic()) return;
90
        if (CommandManager.handle(message)) {
91
            ci.cancel();
92
        }
93
    }
94
95
    @Unique
96
    private boolean combatant$betterChat$shouldHideVanillaChat() {
97
        if (!RuntimeGate.canRunHud()) return false;
98
        if (!BetterChat.isActive()) return false;
99
        BetterChat cfg = BetterChat.get();
100
        return cfg != null && cfg.hideVanilla();
101
    }
102
}
103
ClientClockManagerMixinsrc/main/java/combatant/client/mixins/ClientClockManagerMixin.javaJava · 34 lines · 1.2 KB
@Mixin(ClientClockManager.class)
ClientClockManagerMixin.javaJava · 34 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.ClientClockManager;
11
import net.minecraft.core.Holder;
12
import net.minecraft.world.clock.WorldClock;
13
import net.minecraft.world.clock.WorldClocks;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18
import combatant.client.features.module.Modules;
19
import combatant.client.features.module.modules.visuals.WorldTweaks;
20
21
@Mixin(ClientClockManager.class)
22
public abstract class ClientClockManagerMixin {
23
24
    @Inject(method = "getTotalTicks", at = @At("HEAD"), cancellable = true)
25
    private void combatant$overrideRenderClock(Holder<WorldClock> clock, CallbackInfoReturnable<Long> cir) {
26
        if (clock == null || !clock.is(WorldClocks.OVERWORLD)) return;
27
28
        WorldTweaks worldTweaks = Modules.get(WorldTweaks.class);
29
        if (worldTweaks == null || !worldTweaks.shouldOverrideTime()) return;
30
31
        cir.setReturnValue(worldTweaks.getRenderClockTicks());
32
    }
33
}
34
ClientCommonPacketListenerImplMixinsrc/main/java/combatant/client/mixins/ClientCommonPacketListenerImplMixin.javaJava · 45 lines · 1.7 KB
@Mixin(ClientCommonPacketListenerImpl.class)
ClientCommonPacketListenerImplMixin.javaJava · 45 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
11
import net.minecraft.client.multiplayer.ClientPacketListener;
12
import net.minecraft.network.Connection;
13
import net.minecraft.network.protocol.Packet;
14
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
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.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.features.module.Modules;
22
import combatant.client.features.module.modules.movement.Flight;
23
24
@Mixin(ClientCommonPacketListenerImpl.class)
25
public abstract class ClientCommonPacketListenerImplMixin {
26
27
    @Final
28
    @Shadow
29
    protected Connection connection;
30
31
    @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true)
32
    private void combatant$flightSendPacket(Packet<?> packet, CallbackInfo ci) {
33
        if (!((Object) this instanceof ClientPacketListener)) return;
34
        if (!(packet instanceof ServerboundMovePlayerPacket move)) return;
35
        Flight flight = Modules.get(Flight.class);
36
        if (flight == null || !flight.isEnabled()) return;
37
38
        ServerboundMovePlayerPacket replacement = flight.onSendMovePacket(move);
39
        if (replacement != null && replacement != move) {
40
            ci.cancel();
41
            connection.send(replacement);
42
        }
43
    }
44
}
45
ClientLevelEnvironmentSeedMixinsrc/main/java/combatant/client/mixins/ClientLevelEnvironmentSeedMixin.javaJava · 49 lines · 2.1 KB
@Mixin(ClientLevel.class)
ModifiesClientLevel
ClientLevelEnvironmentSeedMixin.javaJava · 49 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
package combatant.client.mixins;
8
9
import combatant.client.render.world.ClientLevelEnvironmentSeedView;
10
import net.minecraft.client.multiplayer.ClientLevel;
11
import net.minecraft.client.multiplayer.ClientPacketListener;
12
import net.minecraft.client.renderer.extract.LevelExtractor;
13
import net.minecraft.core.Holder;
14
import net.minecraft.resources.ResourceKey;
15
import net.minecraft.world.level.Level;
16
import net.minecraft.world.level.dimension.DimensionType;
17
import org.spongepowered.asm.mixin.Mixin;
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.callback.CallbackInfo;
22
23
/** Keeps the exact seed already supplied to ClientLevel for deterministic renderer weather fields. */
24
@Mixin(ClientLevel.class)
25
public abstract class ClientLevelEnvironmentSeedMixin implements ClientLevelEnvironmentSeedView {
26
    @Unique
27
    private long combatant$environmentSeed;
28
29
    @Inject(method = "<init>", at = @At("RETURN"))
30
    private void combatant$captureEnvironmentSeed(ClientPacketListener connection,
31
                                                   ClientLevel.ClientLevelData levelData,
32
                                                   ResourceKey<Level> dimension,
33
                                                   Holder<DimensionType> dimensionType,
34
                                                   int viewDistance,
35
                                                   int simulationDistance,
36
                                                   LevelExtractor extractor,
37
                                                   boolean debug,
38
                                                   long seed,
39
                                                   int seaLevel,
40
                                                   CallbackInfo ci) {
41
        combatant$environmentSeed = seed;
42
    }
43
44
    @Override
45
    public long combatant$environmentSeed() {
46
        return combatant$environmentSeed;
47
    }
48
}
49
ClientLevelMixinsrc/main/java/combatant/client/mixins/ClientLevelMixin.javaJava · 112 lines · 4.1 KB
@Mixin(ClientLevel.class)
ModifiesClientLevel
ClientLevelMixin.javaJava · 112 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.multiplayer.ClientLevel;
11
import net.minecraft.core.BlockPos;
12
import net.minecraft.core.Direction;
13
import net.minecraft.core.particles.ItemParticleOption;
14
import net.minecraft.core.particles.ParticleOptions;
15
import net.minecraft.core.particles.ParticleTypes;
16
import net.minecraft.world.level.block.Block;
17
import net.minecraft.world.level.block.state.BlockState;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.injection.At;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
import combatant.client.features.module.Modules;
23
import combatant.client.features.module.modules.visuals.NoRender;
24
import combatant.client.util.block.BlockObservationHub;
25
26
@Mixin(ClientLevel.class)
27
public abstract class ClientLevelMixin {
28
29
    @Inject(method = "setServerVerifiedBlockState", at = @At("TAIL"))
30
    private void combatant$recordBlockUpdate(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, CallbackInfo ci) {
31
        BlockObservationHub.observeWorldUpdate(pos, state);
32
    }
33
34
    @Inject(
35
            method = "doAddParticle(Lnet/minecraft/core/particles/ParticleOptions;ZZDDDDDD)V",
36
            at = @At("HEAD"),
37
            cancellable = true
38
    )
39
    private void combatant$noRenderEatParticles(
40
            ParticleOptions effect,
41
            boolean force,
42
            boolean canSpawnOnMinimal,
43
            double x, double y, double z,
44
            double vx, double vy, double vz,
45
            CallbackInfo ci
46
    ) {
47
        NoRender nr = Modules.get(NoRender.class);
48
        if (nr == null || !nr.isEnabled()) return;
49
50
        // частицы еды / питья
51
        if (nr.off("eat_particles")
52
                && effect instanceof ItemParticleOption) {
53
            ci.cancel();
54
        }
55
56
        if (nr.off("hit_particles")) {
57
            var type = effect.getType();
58
            if (type == ParticleTypes.DAMAGE_INDICATOR
59
                    || type == ParticleTypes.CRIT
60
                    || type == ParticleTypes.ENCHANTED_HIT) {
61
                ci.cancel();
62
            }
63
        }
64
65
        if (nr.off("sweep_particles")) {
66
            var type = effect.getType();
67
            if (type == ParticleTypes.SWEEP_ATTACK) {
68
                ci.cancel();
69
            }
70
        }
71
    }
72
73
@Inject(method = "addDestroyBlockEffect", at = @At("HEAD"), cancellable = true)
74
    private void combatant$noRenderBlockBreakParticles(BlockPos pos, BlockState state, CallbackInfo ci) {
75
        NoRender noRender = Modules.get(NoRender.class);
76
        if (noRender != null
77
                && (noRender.offParticle("all_particles") || noRender.offParticle("block_break_particles"))) {
78
            ci.cancel();
79
        }
80
    }
81
82
    @Inject(method = "addBreakingBlockEffect", at = @At("HEAD"), cancellable = true)
83
    private void combatant$noRenderBlockBreakingParticles(BlockPos pos, Direction direction, CallbackInfo ci) {
84
        NoRender noRender = Modules.get(NoRender.class);
85
        if (noRender != null
86
                && (noRender.offParticle("all_particles") || noRender.offParticle("block_breaking_particles"))) {
87
            ci.cancel();
88
        }
89
    }
90
91
    @org.spongepowered.asm.mixin.injection.Redirect(
92
            method = "tickWeatherEffects",
93
            at = @At(
94
                    value = "INVOKE",
95
                    target = "Lnet/minecraft/client/multiplayer/ClientLevel;addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V"
96
            )
97
    )
98
    private void combatant$noRenderRainSplash(
99
            ClientLevel level,
100
            ParticleOptions effect,
101
            double x, double y, double z,
102
            double vx, double vy, double vz
103
    ) {
104
        NoRender noRender = Modules.get(NoRender.class);
105
        if (noRender != null
106
                && (noRender.offParticle("all_particles") || noRender.offParticle("rain_splash_particles"))) {
107
            return;
108
        }
109
        level.addParticle(effect, x, y, z, vx, vy, vz);
110
    }
111
}
112
ClientPacketListenerMixinsrc/main/java/combatant/client/mixins/ClientPacketListenerMixin.javaJava · 432 lines · 17.9 KB
@Mixin(ClientPacketListener.class)
ClientPacketListenerMixin.javaJava · 432 lines · 17.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.multiplayer.ClientLevel;
12
import net.minecraft.client.multiplayer.ClientPacketListener;
13
import net.minecraft.network.chat.Component;
14
import net.minecraft.network.protocol.game.*;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.entity.player.Player;
17
import net.minecraft.world.item.Items;
18
import net.minecraft.world.phys.Vec3;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.Unique;
21
import org.spongepowered.asm.mixin.injection.At;
22
import org.spongepowered.asm.mixin.injection.Inject;
23
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
24
import combatant.client.config.values.ItemCooldownRulesValue;
25
import combatant.client.events.Events;
26
import combatant.client.events.impl.PvpChatEvent;
27
import combatant.client.events.impl.PvpTabEvent;
28
import combatant.client.features.module.Modules;
29
import combatant.client.features.module.modules.combat.PvpCooldowns;
30
import combatant.client.features.module.modules.misc.NoSound;
31
import combatant.client.features.module.modules.movement.Flight;
32
import combatant.client.features.module.modules.visuals.SoundESP;
33
import combatant.client.features.module.modules.visuals.TotemFX;
34
import combatant.client.features.module.modules.visuals.WorldTweaks;
35
import combatant.client.features.relations.StaffTracker;
36
import combatant.client.util.logging.DebugLog;
37
import combatant.client.render.engine.core.CombatantRenderSystem;
38
import combatant.client.render.engine.deferred.DeferredHistoryResetReason;
39
import combatant.client.util.logging.ServerDumpUtil;
40
import combatant.client.util.player.NetworkStatsUtil;
41
import combatant.client.util.player.effect.StatusEffectHeuristics;
42
import combatant.client.util.pvp.client.CooldownsState;
43
import combatant.client.util.pvp.opponents.OpponentCooldownManager;
44
import combatant.client.util.pvp.opponents.TotemPopCounter;
45
46
import java.util.UUID;
47
import java.util.regex.Matcher;
48
import java.util.regex.Pattern;
49
50
@Mixin(ClientPacketListener.class)
51
public abstract class ClientPacketListenerMixin {
52
53
    // "TPS: 20.0" или "TPS: *20.0"
54
    @Unique
55
    private static final Pattern TPS_PATTERN =
56
            Pattern.compile("TPS:\\s*\\*?(\\d+(?:\\.\\d+)?)");
57
    // "Пинг: 57"
58
    @Unique
59
    private static final Pattern PING_PATTERN =
60
            Pattern.compile("Пинг:\\s*(\\d+)");
61
62
    @Inject(method = "handleMovePlayer", at = @At("HEAD"))
63
    private void combatant$invalidateDeferredHistoryOnTeleport(ClientboundPlayerPositionPacket packet, CallbackInfo ci) {
64
        CombatantRenderSystem.deferredWorld().requestHistoryReset(DeferredHistoryResetReason.TELEPORT);
65
    }
66
67
    @Inject(method = "handlePlayerAbilities", at = @At("HEAD"), cancellable = true)
68
    private void combatant$flightAbilities(ClientboundPlayerAbilitiesPacket packet, CallbackInfo ci) {
69
        Flight flight = Modules.get(Flight.class);
70
        if (flight == null || !flight.isEnabled()) return;
71
        if (flight.onReceiveAbilities(packet)) {
72
            ci.cancel();
73
        }
74
    }
75
76
    @Inject(method = "handleTabListCustomisation", at = @At("TAIL"))
77
    private void combatant$captureTab(ClientboundTabListPacket packet, CallbackInfo ci) {
78
        String header = packet.header() == null ? "" : packet.header().getString();
79
        String footer = packet.footer() == null ? "" : packet.footer().getString();
80
        ServerDumpUtil.dumpTabText("HEADER", packet.header());
81
        ServerDumpUtil.dumpTabText("FOOTER", packet.footer());
82
        if (Events.BUS.hasListeners(PvpTabEvent.class)) {
83
            Events.BUS.post(new PvpTabEvent(header, footer));
84
        }
85
    }
86
87
    @Inject(method = "handleSystemChat", at = @At("HEAD"))
88
    private void onChat(ClientboundSystemChatPacket packet, CallbackInfo ci) {
89
        String msg = packet.content().getString();
90
91
        // PvP state listeners via events; legacy direct setters disabled.
92
        if (msg != null && !msg.isBlank() && Events.BUS.hasListeners(PvpChatEvent.class)) {
93
            Events.BUS.post(new PvpChatEvent(msg, PvpChatEvent.Source.GAME_MESSAGE));
94
        }
95
        /*
96
        if (msg.contains("Вы вошли в режим PVP")) {
97
            CooldownsState.MANAGER.enterPvp();
98
        } else if (msg.contains("PVP окончено")) {
99
            CooldownsState.MANAGER.exitPvp();
100
        }
101
        */
102
    }
103
104
    @Inject(method = "handleSoundEvent", at = @At("HEAD"))
105
    private void combatant$onChorus(ClientboundSoundPacket packet, CallbackInfo ci) {
106
        // Opponent cooldown tracking disabled (legacy system).
107
        /*
108
        if (!CooldownsState.shouldTrackOpponents()) return;
109
        if (packet.getSound().value() != SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT) return;
110
111
        MinecraftClient mc = MinecraftClient.getInstance();
112
        if (mc.world == null || mc.player == null) return;
113
114
        Vec3d pos = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
115
116
        if (!SoundEntityResolver.isUnambiguousOpponent(pos, 1.6)) return;
117
118
        PlayerEntity p = SoundEntityResolver.findClosestOpponent(pos, 1.6);
119
        if (p == null) return;
120
121
        OpponentCooldownManager.start(p.getUuid(), Items.CHORUS_FRUIT);
122
        */
123
    }
124
125
    @Inject(method = "handlePlayerChat", at = @At("HEAD"))
126
    private void combatant$pvpChatMessage(ClientboundPlayerChatPacket packet, CallbackInfo ci) {
127
        String msg = packet == null ? null : packet.body().content();
128
        if (msg == null || msg.isBlank()) return;
129
        if (Events.BUS.hasListeners(PvpChatEvent.class)) {
130
            Events.BUS.post(new PvpChatEvent(msg, PvpChatEvent.Source.CHAT_MESSAGE));
131
        }
132
    }
133
134
    @Inject(method = "handleRemoveEntities", at = @At("TAIL"))
135
    private void combatant$onEntitiesDestroy(ClientboundRemoveEntitiesPacket packet, CallbackInfo ci) {
136
137
        Minecraft mc = Minecraft.getInstance();
138
        ClientLevel world = mc.level;
139
        if (world == null) return;
140
141
        for (int id : packet.getEntityIds()) {
142
143
            Entity e = world.getEntity(id);
144
            if (!(e instanceof Player player)) continue;
145
146
            StaffTracker.onEntityDisappear(player.getUUID());
147
        }
148
    }
149
150
    @Inject(method = "handleAddEntity", at = @At("TAIL"))
151
    private void combatant$onEntitySpawn(ClientboundAddEntityPacket packet, CallbackInfo ci) {
152
153
        Minecraft mc = Minecraft.getInstance();
154
        ClientLevel world = mc.level;
155
        if (world == null) return;
156
157
        if (packet.getType() != net.minecraft.world.entity.EntityTypes.PLAYER) return;
158
159
        Entity entity = world.getEntity(packet.getId());
160
        if (!(entity instanceof Player player)) return;
161
162
        StaffTracker.onEntityAppear(player.getUUID(), player.getGameProfile().name());
163
    }
164
165
    @Inject(method = "handlePlayerInfoUpdate", at = @At("TAIL"))
166
    private void combatant$onPlayerList(ClientboundPlayerInfoUpdatePacket packet, CallbackInfo ci) {
167
168
        var actions = packet.actions();
169
        boolean listedAffects = actions.contains(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED)
170
                || actions.contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
171
172
        boolean gmAffects = actions.contains(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE)
173
                || actions.contains(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
174
175
        for (var entry : packet.entries()) {
176
177
            var uuid = entry.profileId();
178
            String name = entry.profile() != null ? entry.profile().name() : null;
179
180
            Boolean listed = listedAffects ? entry.listed() : null;
181
            var gm = gmAffects ? entry.gameMode() : null;
182
183
            // ВАЖНО: берём ПОЛНЫЙ Text из TAB
184
            var displayName = entry.displayName();
185
            if (displayName == null && name != null) {
186
                displayName = net.minecraft.network.chat.Component.literal(name);
187
            }
188
189
            StaffTracker.onTabUpdate(uuid, name, displayName, listed, gm);
190
        }
191
    }
192
193
    @Inject(method = "handlePlayerInfoRemove", at = @At("TAIL"))
194
    private void combatant$onPlayerRemove(ClientboundPlayerInfoRemovePacket packet, CallbackInfo ci) {
195
196
        for (UUID id : packet.profileIds()) {
197
198
            // убрали из TAB
199
            StaffTracker.onTabUpdate(id, null, null, false, null);
200
            TotemPopCounter.onPlayerLogout(id);
201
            // ВАЖНО — фикс VANISH после кика
202
            StaffTracker.onEntityDisappear(id);
203
        }
204
    }
205
206
    @Inject(method = "handleSetTime", at = @At("HEAD"))
207
    private void combatant$captureServerTime(ClientboundSetTimePacket packet, CallbackInfo ci) {
208
        WorldTweaks.setServerTimeOfDay(packet.gameTime());
209
    }
210
211
    @Inject(method = "handleTabListCustomisation", at = @At("TAIL"))
212
    private void combatant$onTab(ClientboundTabListPacket packet, CallbackInfo ci) {
213
        parse(packet.header());
214
    }
215
216
    @Unique
217
    private void parse(Component text) {
218
        if (text == null) return;
219
220
        String raw = text.getString();
221
        if (raw.isEmpty()) return;
222
223
        Matcher tps = TPS_PATTERN.matcher(raw);
224
        if (tps.find()) {
225
            try {
226
                NetworkStatsUtil.updateTabTps(Float.parseFloat(tps.group(1)));
227
            } catch (NumberFormatException ignored) {
228
            }
229
        }
230
231
        Matcher ping = PING_PATTERN.matcher(raw);
232
        if (ping.find()) {
233
            try {
234
                NetworkStatsUtil.updateTabPing(Integer.parseInt(ping.group(1)));
235
            } catch (NumberFormatException ignored) {
236
            }
237
        }
238
    }
239
240
    @Inject(method = "handleContainerSetSlot", at = @At("HEAD"))
241
    private void combatant$debugSlotUpdate(ClientboundContainerSetSlotPacket packet, CallbackInfo ci) {
242
        // PvP cooldown confirmation disabled (legacy system).
243
        /*
244
        int syncId = packet.getSyncId();
245
        int slot = packet.getSlot();
246
        ItemStack stack = packet.getStack();
247
248
        var pending = CooldownsState.PENDING.consumeIfConfirmed(slot, stack.getCount());
249
        if (pending != null) {
250
            CooldownsState.MANAGER.commitConfirmedUse(pending.item(), pending.startedAtMs());
251
        }
252
        */
253
    }
254
255
    @Inject(method = "handleContainerContent", at = @At("HEAD"))
256
    private void combatant$debugFullInventory(ClientboundContainerSetContentPacket packet, CallbackInfo ci) {
257
        // PvP cooldown confirmation disabled (legacy system).
258
        /*
259
        int syncId = packet.syncId();
260
        List<ItemStack> contents = packet.contents();
261
262
        for (int i = 0; i < contents.size(); i++) {
263
            ItemStack stack = contents.get(i);
264
            if (stack.isEmpty()) continue;
265
266
            var pending = CooldownsState.PENDING.consumeIfConfirmed(i, stack.getCount());
267
            if (pending != null) {
268
                CooldownsState.MANAGER.commitConfirmedUse(pending.item(), pending.startedAtMs());
269
            }
270
        }
271
        */
272
    }
273
274
    @Inject(method = "handleSoundEvent", at = @At("HEAD"), cancellable = true)
275
    private void combatant$filterSound(ClientboundSoundPacket packet, CallbackInfo ci) {
276
        NoSound module = Modules.get(NoSound.class);
277
        if (module == null || !module.isEnabled()) return;
278
        if (packet == null || packet.getSound() == null) return;
279
        String id = packet.getSound().value().location().toString().toLowerCase();
280
        if (module.shouldMute(id)) {
281
            ci.cancel();
282
        }
283
    }
284
285
    @Inject(method = "handleSoundEntityEvent", at = @At("HEAD"), cancellable = true)
286
    private void combatant$filterSoundFromEntity(ClientboundSoundEntityPacket packet, CallbackInfo ci) {
287
        NoSound module = Modules.get(NoSound.class);
288
        if (module == null || !module.isEnabled()) return;
289
        if (packet == null || packet.getSound() == null) return;
290
        String id = packet.getSound().value().location().toString().toLowerCase();
291
        if (module.shouldMute(id)) {
292
            ci.cancel();
293
        }
294
    }
295
296
    @Inject(method = "handleParticleEvent", at = @At("HEAD"))
297
    private void combatant$heuristicParticle(ClientboundLevelParticlesPacket packet, CallbackInfo ci) {
298
        var p = packet.getParticle();
299
        // Log raw particles once per hook for diagnostics
300
        DebugLog.info("Particle packet type=%s pos=%.2f %.2f %.2f count=%d",
301
                p.getType().toString(),
302
                packet.getX(), packet.getY(), packet.getZ(),
303
                packet.getCount());
304
        StatusEffectHeuristics.handle(p, packet.getX(), packet.getY(), packet.getZ());
305
    }
306
307
    @Inject(method = "handleSoundEvent", at = @At("HEAD"))
308
    private void combatant$onPearl(ClientboundSoundPacket packet, CallbackInfo ci) {
309
        // Opponent cooldown tracking disabled (legacy system).
310
        /*
311
        if (!CooldownsState.shouldTrackOpponents()) return;
312
        if (packet.getSound().value() != SoundEvents.ENTITY_ENDER_PEARL_THROW) return;
313
314
        MinecraftClient mc = MinecraftClient.getInstance();
315
        if (mc.world == null || mc.player == null) return;
316
317
        Vec3d pos = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
318
319
        if (!SoundEntityResolver.isUnambiguousOpponent(pos, 1.6)) return;
320
321
        PlayerEntity p = SoundEntityResolver.findClosestOpponent(pos, 1.6);
322
        if (p == null) return;
323
324
        OpponentCooldownManager.start(p.getUuid(), Items.ENDER_PEARL);
325
        */
326
    }
327
328
    @Inject(method = "handleSoundEvent", at = @At("HEAD"))
329
    private void combatant$onPlaySound(ClientboundSoundPacket packet, CallbackInfo ci) {
330
        SoundESP esp = Modules.get(SoundESP.class);
331
        if (esp == null || !esp.isEnabled()) return;
332
        if (packet == null || packet.getSound() == null) return;
333
        Vec3 pos = new Vec3(packet.getX(), packet.getY(), packet.getZ());
334
        esp.handleSound(packet.getSound().value().location(), pos);
335
    }
336
337
    @Inject(method = "handleSoundEntityEvent", at = @At("HEAD"))
338
    private void combatant$onPlaySoundFromEntity(ClientboundSoundEntityPacket packet, CallbackInfo ci) {
339
        SoundESP esp = Modules.get(SoundESP.class);
340
        if (esp == null || !esp.isEnabled()) return;
341
        if (packet == null || packet.getSound() == null) return;
342
343
        Minecraft mc = Minecraft.getInstance();
344
        if (mc.level == null) return;
345
        Entity entity = mc.level.getEntity(packet.getId());
346
        if (entity == null) return;
347
348
        esp.handleSound(packet.getSound().value().location(), entity.position());
349
    }
350
351
    @Inject(method = "handleUpdateMobEffect", at = @At("HEAD"))
352
    private void combatant$logStatusEffect(ClientboundUpdateMobEffectPacket packet, CallbackInfo ci) {
353
        DebugLog.server("Packet: add/refresh effect eid=%d effect=%s amp=%d dur=%d particles=%s icon=%s ambient=%s keepFading=%s",
354
                packet.getEntityId(),
355
                packet.getEffect().unwrapKey().map(k -> k.identifier().toString()).orElse("unknown"),
356
                packet.getEffectAmplifier(),
357
                packet.getEffectDurationTicks(),
358
                packet.isEffectVisible(),
359
                packet.effectShowsIcon(),
360
                packet.isEffectAmbient(),
361
                packet.shouldBlend()
362
        );
363
    }
364
365
    @Inject(method = "handleRemoveMobEffect", at = @At("HEAD"))
366
    private void combatant$logRemove(ClientboundRemoveMobEffectPacket packet, CallbackInfo ci) {
367
        DebugLog.server("Packet: remove effect eid=%d (%s) effect=%s",
368
                packet.entityId(),
369
                resolveName(packet.entityId()),
370
                packet.effect().unwrapKey().map(k -> k.identifier().toString()).orElse("unknown"));
371
    }
372
373
    @Unique
374
    private String resolveName(int entityId) {
375
        var mc = Minecraft.getInstance();
376
        if (mc == null || mc.level == null) return "unknown";
377
        Entity e = mc.level.getEntity(entityId);
378
        if (e == null) return "unknown";
379
        if (e instanceof Player p) return p.getName().getString();
380
        return e.getName().getString();
381
    }
382
383
    @Inject(method = "handleSoundEvent", at = @At("HEAD"))
384
    private void combatant$onTotemSound(ClientboundSoundPacket packet, CallbackInfo ci) {
385
        // Opponent cooldown tracking disabled (legacy system).
386
        /*
387
        if (!CooldownsState.shouldTrackOpponents()) return;
388
        if (packet.getSound().value() != SoundEvents.ITEM_TOTEM_USE) return;
389
390
        MinecraftClient mc = MinecraftClient.getInstance();
391
        if (mc.world == null || mc.player == null) return;
392
393
        Vec3d pos = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
394
395
        if (!SoundEntityResolver.isUnambiguousOpponent(pos, 1.6)) return;
396
397
        PlayerEntity p = SoundEntityResolver.findClosestOpponent(pos, 1.6);
398
        if (p == null) return;
399
400
        OpponentCooldownManager.start(p.getUuid(), Items.TOTEM_OF_UNDYING);
401
        */
402
    }
403
404
    @Inject(method = "handleEntityEvent", at = @At("HEAD"))
405
    private void combatant$onTotemStatus(ClientboundEntityEventPacket packet, CallbackInfo ci) {
406
        if (packet.getEventId() == 35) { // 35 = сработал тотем бессмертия
407
            ClientPacketListener handler = (ClientPacketListener) (Object) this;
408
            Minecraft client = Minecraft.getInstance();
409
410
            Entity entity = packet.getEntity(handler.getLevel());
411
            if (entity == null) return;
412
            if (entity.equals(client.player)) {
413
                PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
414
                if (cooldowns != null) {
415
                    cooldowns.tryStartLocalCooldown(Items.TOTEM_OF_UNDYING, ItemCooldownRulesValue.Trigger.TOTEM_POP);
416
                }
417
                TotemFX fx = Modules.get(TotemFX.class);
418
                if (fx != null) {
419
                    fx.onTotemPop();
420
                }
421
                return;
422
            }
423
            if (entity instanceof Player player) {
424
                TotemPopCounter.recordPop(player);
425
                if (CooldownsState.shouldTrackOpponents()) {
426
                    OpponentCooldownManager.recordUse(player.getUUID(), Items.TOTEM_OF_UNDYING);
427
                }
428
            }
429
        }
430
    }
431
}
432
CommandEncoderMixinsrc/main/java/combatant/client/mixins/CommandEncoderMixin.javaJava · 300 lines · 14.6 KB
@Mixin(CommandEncoder.class)
CommandEncoderMixin.javaJava · 300 lines · 14.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.systems.CommandEncoder;
11
import com.mojang.blaze3d.systems.CommandEncoderBackend;
12
import com.mojang.blaze3d.systems.RenderPassBackend;
13
import com.mojang.blaze3d.systems.RenderPass;
14
import com.mojang.blaze3d.systems.RenderPassDescriptor;
15
import com.mojang.blaze3d.systems.RenderSystem;
16
import com.mojang.blaze3d.buffers.GpuBuffer;
17
import com.mojang.blaze3d.buffers.GpuBufferSlice;
18
import com.mojang.blaze3d.buffers.GpuFence;
19
import com.mojang.blaze3d.textures.GpuTexture;
20
import com.mojang.blaze3d.textures.GpuTextureView;
21
import org.jetbrains.annotations.Nullable;
22
import org.joml.Vector4fc;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Unique;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.Redirect;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30
import combatant.client.render.engine.core.CombatantRenderSystem;
31
import combatant.client.render.engine.profiler.ProfilerPhase;
32
import combatant.client.render.engine.rhi.scissor.GlobalScissorState;
33
import combatant.client.util.logging.DebugLog;
34
35
import java.nio.ByteBuffer;
36
import java.util.List;
37
import java.util.Optional;
38
import java.util.OptionalDouble;
39
import java.util.function.Supplier;
40
41
@Mixin(CommandEncoder.class)
42
public abstract class CommandEncoderMixin {
43
    @Unique
44
    private static String combatant$label(Supplier<String> label) {
45
        try {
46
            return label != null ? label.get() : "<null-label>";
47
        } catch (Throwable t) {
48
            return "<label-threw-" + t.getClass().getSimpleName() + ">";
49
        }
50
    }
51
52
    @Unique
53
    private static @Nullable GpuTextureView combatant$firstColorView(
54
            List<RenderPassDescriptor.Attachment<Optional<Vector4fc>>> colorAttachments
55
    ) {
56
        if (colorAttachments == null) {
57
            return null;
58
        }
59
        for (RenderPassDescriptor.Attachment<Optional<Vector4fc>> attachment : colorAttachments) {
60
            if (attachment != null) {
61
                return attachment.textureView();
62
            }
63
        }
64
        return null;
65
    }
66
67
    @Unique
68
    private static @Nullable GpuTextureView combatant$depthView(
69
            @Nullable RenderPassDescriptor.Attachment<OptionalDouble> depthAttachment
70
    ) {
71
        return depthAttachment == null ? null : depthAttachment.textureView();
72
    }
73
74
75
    @Unique
76
    private static boolean combatant$isVulkanBackend() {
77
        try {
78
            if (RenderSystem.getDevice() == null || RenderSystem.getDevice().getDeviceInfo() == null) return false;
79
            String backendName = RenderSystem.getDevice().getDeviceInfo().backendName();
80
            return backendName != null && backendName.toLowerCase(java.util.Locale.ROOT).contains("vulkan");
81
        } catch (Throwable ignored) {
82
            return false;
83
        }
84
    }
85
86
    @Inject(method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;", at = @At("RETURN"))
87
    private void combatant$onCreateRenderPass(
88
            RenderPassDescriptor descriptor,
89
            CallbackInfoReturnable<RenderPass> cir
90
    ) {
91
        RenderPass pass = cir.getReturnValue();
92
        if (pass == null || descriptor == null) {
93
            return;
94
        }
95
        try {
96
            // A newly created Blaze3D pass is an explicit ownership boundary. GL-native state
97
            // not represented by GlStateManager must be considered unknown before Combatant applies it.
98
            CombatantRenderSystem.rhi().pipelineState().invalidateForeignState();
99
        } catch (Throwable t) {
100
            DebugLog.error("[RHI] render pass native-state boundary hook failed for %s", t, combatant$label(descriptor.label()));
101
        }
102
        try {
103
            GlobalScissorState.applyTo(pass, descriptor.renderArea);
104
        } catch (Throwable t) {
105
            DebugLog.error("[Scissor] render pass scissor hook failed for %s", t, combatant$label(descriptor.label()));
106
        }
107
108
        try {
109
            CombatantRenderSystem.rhi().shapeClip().beginRenderPass(
110
                    combatant$label(descriptor.label()),
111
                    combatant$firstColorView(descriptor.colorAttachments()),
112
                    combatant$depthView(descriptor.depthAttachment())
113
            );
114
        } catch (Throwable t) {
115
            DebugLog.error("[ShapeClip] beginRenderPass hook failed for %s", t, combatant$label(descriptor.label()));
116
        }
117
    }
118
119
    @Inject(method = "submitRenderPass", at = @At("HEAD"))
120
    private void combatant$resetRhiRenderPassState(CallbackInfo ci) {
121
        if (combatant$isVulkanBackend()) {
122
            return;
123
        }
124
        try {
125
            CombatantRenderSystem.rhi().pipelineState().resetRenderPassState();
126
        } catch (Throwable t) {
127
            DebugLog.error("[ShapeClip/GL] render pass reset hook failed", t);
128
        }
129
    }
130
131
    @Inject(method = "submitRenderPass", at = @At("RETURN"))
132
    private void combatant$invalidateRhiNativeStateAfterSubmit(CallbackInfo ci) {
133
        if (combatant$isVulkanBackend()) {
134
            return;
135
        }
136
        try {
137
            // Blaze3D has just executed/closed a pass and may have changed native GL state behind
138
            // Combatant's narrow stencil/MSAA tracker. Never carry that shadow into the next pass.
139
            CombatantRenderSystem.rhi().pipelineState().invalidateForeignState();
140
        } catch (Throwable t) {
141
            DebugLog.error("[RHI/GL] post-render-pass native-state invalidation failed", t);
142
        }
143
    }
144
145
    @Redirect(
146
            method = "submit",
147
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;submit()V")
148
    )
149
    private void combatant$profileCommandSubmit(CommandEncoderBackend backend) {
150
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:submit")) {
151
            backend.submit();
152
        }
153
    }
154
155
    @Redirect(
156
            method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;",
157
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPassBackend;")
158
    )
159
    private RenderPassBackend combatant$profileCreateRenderPass(CommandEncoderBackend backend, RenderPassDescriptor descriptor) {
160
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:create_render_pass")) {
161
            return backend.createRenderPass(descriptor);
162
        }
163
    }
164
165
    @Redirect(
166
            method = "submitRenderPass",
167
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;submitRenderPass()V")
168
    )
169
    private void combatant$profileSubmitRenderPass(CommandEncoderBackend backend) {
170
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:submit_render_pass")) {
171
            backend.submitRenderPass();
172
        }
173
    }
174
175
    @Redirect(
176
            method = "writeToBuffer",
177
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;writeToBuffer(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Ljava/nio/ByteBuffer;)V")
178
    )
179
    private void combatant$profileWriteBuffer(CommandEncoderBackend backend, GpuBufferSlice buffer, ByteBuffer data) {
180
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:write_buffer")) {
181
            backend.writeToBuffer(buffer, data);
182
        }
183
    }
184
185
    @Redirect(
186
            method = "copyToBuffer",
187
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;copyToBuffer(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V")
188
    )
189
    private void combatant$profileCopyBuffer(CommandEncoderBackend backend, GpuBufferSlice source, GpuBufferSlice target) {
190
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:copy_buffer")) {
191
            backend.copyToBuffer(source, target);
192
        }
193
    }
194
195
    @Redirect(
196
            method = "writeToTexture(Lcom/mojang/blaze3d/textures/GpuTexture;Ljava/nio/ByteBuffer;IIIIII)V",
197
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;writeToTexture(Lcom/mojang/blaze3d/textures/GpuTexture;Ljava/nio/ByteBuffer;IIIIII)V")
198
    )
199
    private void combatant$profileWriteTexture(CommandEncoderBackend backend,
200
                                                GpuTexture texture,
201
                                                ByteBuffer data,
202
                                                int mipLevel,
203
                                                int x,
204
                                                int y,
205
                                                int width,
206
                                                int height,
207
                                                int rowPitch) {
208
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:write_texture")) {
209
            backend.writeToTexture(texture, data, mipLevel, x, y, width, height, rowPitch);
210
        }
211
    }
212
213
    @Redirect(
214
            method = "copyBufferToTexture",
215
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;copyBufferToTexture(Lcom/mojang/blaze3d/buffers/GpuBufferSlice;IIIILcom/mojang/blaze3d/textures/GpuTexture;IIIIII)V")
216
    )
217
    private void combatant$profileCopyBufferToTexture(CommandEncoderBackend backend,
218
                                                       GpuBufferSlice source,
219
                                                       int rowPitch,
220
                                                       int imageHeight,
221
                                                       int sourceOffsetX,
222
                                                       int sourceOffsetY,
223
                                                       GpuTexture target,
224
                                                       int mipLevel,
225
                                                       int targetX,
226
                                                       int targetY,
227
                                                       int width,
228
                                                       int height,
229
                                                       int depth) {
230
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:copy_buffer_to_texture")) {
231
            backend.copyBufferToTexture(source, rowPitch, imageHeight, sourceOffsetX, sourceOffsetY,
232
                    target, mipLevel, targetX, targetY, width, height, depth);
233
        }
234
    }
235
236
    @Redirect(
237
            method = "copyTextureToBuffer(Lcom/mojang/blaze3d/textures/GpuTexture;Lcom/mojang/blaze3d/buffers/GpuBuffer;JLjava/lang/Runnable;I)V",
238
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;copyTextureToBuffer(Lcom/mojang/blaze3d/textures/GpuTexture;Lcom/mojang/blaze3d/buffers/GpuBuffer;JLjava/lang/Runnable;I)V")
239
    )
240
    private void combatant$profileCopyTextureToBuffer(CommandEncoderBackend backend,
241
                                                       GpuTexture source,
242
                                                       GpuBuffer target,
243
                                                       long offset,
244
                                                       Runnable callback,
245
                                                       int mipLevel) {
246
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:readback_texture")) {
247
            backend.copyTextureToBuffer(source, target, offset, callback, mipLevel);
248
        }
249
    }
250
251
    @Redirect(
252
            method = "copyTextureToBuffer(Lcom/mojang/blaze3d/textures/GpuTexture;Lcom/mojang/blaze3d/buffers/GpuBuffer;JLjava/lang/Runnable;IIIII)V",
253
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;copyTextureToBuffer(Lcom/mojang/blaze3d/textures/GpuTexture;Lcom/mojang/blaze3d/buffers/GpuBuffer;JLjava/lang/Runnable;IIIII)V")
254
    )
255
    private void combatant$profileCopyTextureRegionToBuffer(CommandEncoderBackend backend,
256
                                                             GpuTexture source,
257
                                                             GpuBuffer target,
258
                                                             long offset,
259
                                                             Runnable callback,
260
                                                             int mipLevel,
261
                                                             int x,
262
                                                             int y,
263
                                                             int width,
264
                                                             int height) {
265
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:readback_texture_region")) {
266
            backend.copyTextureToBuffer(source, target, offset, callback, mipLevel, x, y, width, height);
267
        }
268
    }
269
270
    @Redirect(
271
            method = "copyTextureToTexture",
272
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;copyTextureToTexture(Lcom/mojang/blaze3d/textures/GpuTexture;Lcom/mojang/blaze3d/textures/GpuTexture;IIIIIII)V")
273
    )
274
    private void combatant$profileCopyTexture(CommandEncoderBackend backend,
275
                                               GpuTexture source,
276
                                               GpuTexture target,
277
                                               int sourceX,
278
                                               int sourceY,
279
                                               int targetX,
280
                                               int targetY,
281
                                               int width,
282
                                               int height,
283
                                               int mipLevel) {
284
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:copy_texture")) {
285
            backend.copyTextureToTexture(source, target, sourceX, sourceY, targetX, targetY, width, height, mipLevel);
286
        }
287
    }
288
289
    @Redirect(
290
            method = "createFence",
291
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;createFence()Lcom/mojang/blaze3d/buffers/GpuFence;")
292
    )
293
    private GpuFence combatant$profileCreateFence(CommandEncoderBackend backend) {
294
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_api:create_fence")) {
295
            return backend.createFence();
296
        }
297
    }
298
299
}
300
ConnectionMixinsrc/main/java/combatant/client/mixins/ConnectionMixin.javaJava · 103 lines · 4.1 KB
@Mixin(Connection.class)
ModifiesConnection
ConnectionMixin.javaJava · 103 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import io.netty.channel.ChannelPipeline;
11
import net.minecraft.network.Connection;
12
import net.minecraft.network.PacketListener;
13
import net.minecraft.network.protocol.Packet;
14
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
15
import net.minecraft.server.RunningOnDifferentThreadException;
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.callback.CallbackInfo;
22
import combatant.client.events.Events;
23
import combatant.client.events.impl.PacketEvent;
24
import combatant.client.util.network.BlinkManager;
25
import combatant.client.util.proxy.ProxyNettyInstaller;
26
27
@Mixin(Connection.class)
28
public class ConnectionMixin {
29
30
    @Shadow
31
    private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
32
        throw new AssertionError();
33
    }
34
35
    @Inject(method = "genericsFtw", at = @At("HEAD"), cancellable = true)
36
    private static <T extends PacketListener> void combatant$onHandlePacket(Packet<T> packet, PacketListener listener, CallbackInfo ci) {
37
        if (BlinkManager.isSilentlyHandlingPackets()) return;
38
        if (!Events.BUS.hasListeners(PacketEvent.Receive.class)) return;
39
        if (packet instanceof ClientboundBundlePacket packs) {
40
            ci.cancel();
41
            for (Packet<?> p : packs.subPackets()) {
42
                try {
43
                    combatant$handlePacketUnchecked(p, listener);
44
                } catch (RunningOnDifferentThreadException ignored) {
45
                }
46
            }
47
        } else {
48
            PacketEvent.Receive event = new PacketEvent.Receive(packet);
49
            Events.BUS.post(event);
50
            if (event.isCancelled()) {
51
                ci.cancel();
52
            }
53
        }
54
    }
55
56
    @Unique
57
    @SuppressWarnings({"rawtypes", "unchecked"})
58
    private static void combatant$handlePacketUnchecked(Packet<?> packet, PacketListener listener) {
59
        ConnectionMixin.genericsFtw((Packet) packet, listener);
60
    }
61
62
    @Inject(method = "genericsFtw", at = @At("TAIL"))
63
    private static <T extends PacketListener> void combatant$onHandlePacketPost(Packet<T> packet, PacketListener listener, CallbackInfo ci) {
64
        if (BlinkManager.isSilentlyHandlingPackets()) return;
65
        if (!Events.BUS.hasListeners(PacketEvent.ReceivePost.class)) return;
66
        if (packet instanceof ClientboundBundlePacket packs) {
67
            for (Packet<?> p : packs.subPackets()) {
68
                PacketEvent.ReceivePost event = new PacketEvent.ReceivePost(p);
69
                Events.BUS.post(event);
70
            }
71
        } else {
72
            PacketEvent.ReceivePost event = new PacketEvent.ReceivePost(packet);
73
            Events.BUS.post(event);
74
        }
75
    }
76
77
    @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true)
78
    private void combatant$onSendPacketPre(Packet<?> packet, CallbackInfo ci) {
79
        if (BlinkManager.isSilentlyHandlingPackets()) return;
80
        if (!Events.BUS.hasListeners(PacketEvent.Send.class)) return;
81
        PacketEvent.Send event = new PacketEvent.Send(packet);
82
        Events.BUS.post(event);
83
        if (event.isCancelled()) {
84
            ci.cancel();
85
        }
86
    }
87
88
    @Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("RETURN"))
89
    private void combatant$onSendPacketPost(Packet<?> packet, CallbackInfo ci) {
90
        if (BlinkManager.isSilentlyHandlingPackets()) return;
91
        if (!Events.BUS.hasListeners(PacketEvent.SendPost.class)) return;
92
        PacketEvent.SendPost event = new PacketEvent.SendPost(packet);
93
        Events.BUS.post(event);
94
    }
95
96
    @Inject(method = "configurePacketHandler", at = @At("HEAD"))
97
    private void combatant$installProxyHandler(ChannelPipeline pipeline, CallbackInfo ci) {
98
        ProxyNettyInstaller.install(pipeline);
99
    }
100
101
102
}
103
ContextualBarMixinsrc/main/java/combatant/client/mixins/ContextualBarMixin.javaJava · 41 lines · 1.5 KB
@Mixin(ContextualBar.class)
ContextualBarMixin.javaJava · 41 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.gui.Font;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.contextualbar.ContextualBar;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
19
import combatant.client.runtime.RuntimeGate;
20
21
@Mixin(ContextualBar.class)
22
public interface ContextualBarMixin {
23
24
    @Inject(method = "extractExperienceLevel", at = @At("HEAD"), cancellable = true)
25
    private static void combatant$drawExperienceLevel(GuiGraphicsExtractor context,
26
                                                      Font textRenderer,
27
                                                      int level,
28
                                                      CallbackInfo ci) {
29
        if (!RuntimeGate.canRunHud()) return;
30
        Minecraft mc = Minecraft.getInstance();
31
        if (mc == null || mc.player == null) return;
32
33
        CustomBar bar = CustomBar.get();
34
        if (bar == null) return;
35
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
36
37
        ci.cancel();
38
    }
39
}
40
41
CycleButtonMixinsrc/main/java/combatant/client/mixins/CycleButtonMixin.javaJava · 53 lines · 2.2 KB
@Mixin(CycleButton.class)
ModifiesCycleButton
CycleButtonMixin.javaJava · 53 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.AbstractWidget;
14
import net.minecraft.client.gui.components.CycleButton;
15
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
16
import net.minecraft.resources.Identifier;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
22
import combatant.client.mixins.accessors.CyclingButtonWidgetAccessor;
23
24
@Mixin(CycleButton.class)
25
public abstract class CycleButtonMixin<T> {
26
27
    @Inject(method = "extractContents(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
28
    private void combatant$drawIcon(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
29
        BetterButtons buttons = BetterButtons.get();
30
        if (buttons == null || !buttons.useUiButtons()) return;
31
        Minecraft mc = Minecraft.getInstance();
32
        if (mc != null && ClientScreen.current() instanceof MerchantScreen) return;
33
        CycleButton<T> self = (CycleButton<T>) (Object) this;
34
        AbstractWidget widget = self;
35
36
        boolean hovered = widget.isMouseOver(mouseX, mouseY);
37
        float hover = BetterButtons.updateHover(widget, hovered, mouseX, mouseY);
38
39
        CyclingButtonWidgetAccessor<T> accessor = (CyclingButtonWidgetAccessor<T>) self;
40
        Identifier icon = accessor.combatant$getIcon() != null
41
                ? accessor.combatant$getIcon().apply(self, self.getValue())
42
                : null;
43
44
        boolean showLabel = accessor.combatant$getLabelType() != CycleButton.DisplayState.HIDE;
45
        BetterButtons.enqueueCyclingButton(self, icon, showLabel, hover, widget.isActive(), widget.isFocused());
46
47
        ci.cancel();
48
    }
49
}
50
51
52
53
DebugHudMixinsrc/main/java/combatant/client/mixins/DebugHudMixin.javaJava · 165 lines · 7.0 KB
@Mixin(DebugScreenOverlay.class)
DebugHudMixin.javaJava · 165 lines · 7.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.GuiGraphicsExtractor;
11
import net.minecraft.client.gui.components.DebugScreenOverlay;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.ModifyArg;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
import combatant.client.config.MainConfig;
18
import combatant.client.features.gui.hud.nondraggable.impl.DebugHudReplacement;
19
import combatant.client.render.engine.core.CombatantRenderSystem;
20
import combatant.client.render.engine.debug.RenderThread2DDebugRenderer;
21
import combatant.client.render.engine.msaa.MsaaWorldTarget;
22
import combatant.client.render.engine.renderer.Renderer2D;
23
import combatant.client.render.engine.text.FontDebugStats;
24
import combatant.client.runtime.RuntimeGate;
25
import combatant.client.util.logging.DebugMode;
26
import combatant.client.util.sound.SoundDebugStats;
27
28
import java.util.ArrayList;
29
import java.util.List;
30
31
@Mixin(DebugScreenOverlay.class)
32
public abstract class DebugHudMixin {
33
34
    @Inject(method = "extractRenderState", at = @At("HEAD"))
35
    private void combatant$beginDebugHudReplacementFrame(GuiGraphicsExtractor context, CallbackInfo ci) {
36
        DebugHudReplacement.beginExtractFrame();
37
    }
38
39
    @Inject(method = "extractLines", at = @At("HEAD"), cancellable = true)
40
    private void combatant$captureDebugHudLines(GuiGraphicsExtractor context,
41
                                                 List<String> lines,
42
                                                 boolean leftAligned,
43
                                                 CallbackInfo ci) {
44
        if (!RuntimeGate.canRunHud() || RuntimeGate.isPanic()) return;
45
        DebugHudReplacement.captureLines(lines, leftAligned);
46
        ci.cancel();
47
    }
48
49
    @ModifyArg(
50
            method = "extractRenderState",
51
            at = @At(
52
                    value = "INVOKE",
53
                    target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;extractLines(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Ljava/util/List;Z)V",
54
                    ordinal = 0
55
            ),
56
            index = 1
57
    )
58
    private List<String> combatant$addEngineInfo(List<String> list) {
59
        if (RuntimeGate.isPanic() || list == null) return list;
60
        DebugMode debugMode = MainConfig.get().getDebugMode();
61
        if (debugMode != DebugMode.ALL && debugMode != DebugMode.RENDER_THREAD) return list;
62
63
        int samples = MainConfig.get().getMsaa3dSamples();
64
        boolean supported = CombatantRenderSystem.rhi().msaa().supported();
65
        MsaaWorldTarget.DebugStatus msaaStatus = MsaaWorldTarget.debugStatus();
66
        String msaa;
67
        if (samples <= 1) {
68
            msaa = "msaa: off";
69
        } else if (supported) {
70
            msaa = String.format("msaa: cfg=%dx target=%dx %s %dx%d alloc=%s active=%s resolve=%s",
71
                    samples,
72
                    msaaStatus.targetSamples(),
73
                    msaaStatus.state(),
74
                    msaaStatus.width(),
75
                    msaaStatus.height(),
76
                    msaaStatus.allocated() ? "yes" : "no",
77
                    msaaStatus.active() ? "yes" : "no",
78
                    msaaStatus.lastResolveOk() ? "ok" : "no"
79
            );
80
        } else {
81
            msaa = "msaa: unavailable";
82
        }
83
84
        List<String> out = new ArrayList<>(list.size() + 20);
85
        out.add("§cCombatant Engine");
86
        out.add("status:§aok");
87
        out.add(msaa);
88
89
        RenderThread2DDebugRenderer.Snapshot debug2d = RenderThread2DDebugRenderer.snapshot();
90
        out.add(String.format("2d rt gui: frame=%d gui=%dx%d rects=%d err=%s",
91
                debug2d.guiStateFrame(),
92
                debug2d.guiWidth(),
93
                debug2d.guiHeight(),
94
                debug2d.guiStateRects(),
95
                debug2d.guiStateError() == null || debug2d.guiStateError().isBlank() ? "none" : debug2d.guiStateError()
96
        ));
97
        out.add(String.format("2d rt imm: frame=%d fb=%dx%d draws=%d/%d v=%d i=%d err=%s",
98
                debug2d.immediateFrame(),
99
                debug2d.framebufferWidth(),
100
                debug2d.framebufferHeight(),
101
                debug2d.immediateDraws(),
102
                debug2d.immediateBatches(),
103
                debug2d.immediateVertices(),
104
                debug2d.immediateIndices(),
105
                debug2d.immediateError() == null || debug2d.immediateError().isBlank() ? "none" : debug2d.immediateError()
106
        ));
107
108
        Renderer2D.BatchStats batchStats = Renderer2D.getBatchStats();
109
        out.add(String.format("ui batch: %s, last %d draws / %d batches",
110
                batchStats.isActive() ? "active" : "idle",
111
                batchStats.getLastDraws(),
112
                batchStats.getLastOrder()
113
        ));
114
        out.add(String.format("ui batch frame: %d draws / %d batches",
115
                batchStats.getFrameDraws(),
116
                batchStats.getFrameBatches()
117
        ));
118
        out.add(String.format("ui batch geom: v=%d, i=%d, pool=%d",
119
                batchStats.getLastVertices(),
120
                batchStats.getLastIndices(),
121
                batchStats.getPoolTotal()
122
        ));
123
        out.add(String.format("ui batch frame geom: v=%d, i=%d",
124
                batchStats.getFrameVertices(),
125
                batchStats.getFrameIndices()
126
        ));
127
        if (batchStats.getLastError() != null && !batchStats.getLastError().isBlank()) {
128
            out.add("ui batch warn: " + batchStats.getLastError());
129
        }
130
131
        out.add(String.format("text msdf: ok=%d, fb=%d, attempts=%d",
132
                FontDebugStats.getMsdfSuccess(),
133
                FontDebugStats.getMsdfFallbacks(),
134
                FontDebugStats.getMsdfAttempts()
135
        ));
136
        if (!FontDebugStats.getLastMsdfFallback().isBlank()) {
137
            String reason = FontDebugStats.getLastMsdfFallbackReason();
138
            out.add("text msdf last fb: " + FontDebugStats.getLastMsdfFallback()
139
                    + (reason.isBlank() ? "" : " (" + reason + ")"));
140
        }
141
142
        out.add(String.format("wav(al): buffers %d/%d, sources %d/%d",
143
                SoundDebugStats.getBuffersAlive(),
144
                SoundDebugStats.getBuffersCreated(),
145
                SoundDebugStats.getSourcesAlive(),
146
                SoundDebugStats.getSourcesCreated()
147
        ));
148
        out.add(String.format("wav(al): allocs=%d (buf=%d, src=%d)",
149
                SoundDebugStats.getBuffersCreated() + SoundDebugStats.getSourcesCreated(),
150
                SoundDebugStats.getBuffersCreated(),
151
                SoundDebugStats.getSourcesCreated()
152
        ));
153
        out.add(String.format("wav(al): uploads=%d, bytes=%.2f MB",
154
                SoundDebugStats.getBufferUploads(),
155
                SoundDebugStats.getBufferBytes() / (1024.0 * 1024.0)
156
        ));
157
        out.add("");
158
        out.addAll(list);
159
        return out;
160
    }
161
}
162
163
164
165
DynamicUniformStorageMixinsrc/main/java/combatant/client/mixins/DynamicUniformStorageMixin.javaJava · 43 lines · 1.4 KB
@Mixin(DynamicUniformStorage.class)
ModifiesDynamicUniformStorage not in 26.3
DynamicUniformStorageMixin.javaJava · 43 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.DynamicUniformStorage;
11
import org.slf4j.Logger;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Shadow;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Redirect;
17
import combatant.client.util.logging.DebugLog;
18
19
@Mixin(DynamicUniformStorage.class)
20
public abstract class DynamicUniformStorageMixin {
21
    @Final
22
    @Shadow
23
    private String label;
24
25
    @Redirect(
26
            method = {"writeUniform", "writeUniforms"},
27
            at = @At(
28
                    value = "INVOKE",
29
                    target = "Lorg/slf4j/Logger;info(Ljava/lang/String;[Ljava/lang/Object;)V"
30
            )
31
    )
32
    private void combatant$redirectResizeLog(Logger logger, String format, Object[] args) {
33
        if (label != null && label.startsWith("Combatant")) {
34
            String message = "Resizing " + args[0]
35
                    + ", capacity limit of " + args[1]
36
                    + " reached during a single frame. New capacity will be " + args[2] + ".";
37
            DebugLog.renderThread("%s", message);
38
            return;
39
        }
40
        logger.info(format, args);
41
    }
42
}
43
EnchantTableRendererMixinsrc/main/java/combatant/client/mixins/EnchantTableRendererMixin.javaJava · 42 lines · 1.7 KB
@Mixin(value = EnchantTableRenderer.class, priority = 1200)priority 1200
EnchantTableRendererMixin.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import combatant.client.features.module.Modules;
12
import combatant.client.features.module.modules.visuals.NoRender;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.blockentity.EnchantTableRenderer;
15
import net.minecraft.client.renderer.blockentity.state.EnchantTableRenderState;
16
import net.minecraft.client.renderer.state.level.CameraRenderState;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
@Mixin(value = EnchantTableRenderer.class, priority = 1200)
23
public abstract class EnchantTableRendererMixin {
24
    @Inject(
25
            method = "submit(Lnet/minecraft/client/renderer/blockentity/state/EnchantTableRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
26
            at = @At("HEAD"),
27
            cancellable = true
28
    )
29
    private void combatant$noRenderEnchantingBook(
30
            EnchantTableRenderState state,
31
            PoseStack poseStack,
32
            SubmitNodeCollector collector,
33
            CameraRenderState cameraState,
34
            CallbackInfo ci
35
    ) {
36
        NoRender noRender = Modules.get(NoRender.class);
37
        if (noRender != null && noRender.offEntity("enchanting_table_book")) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
EntityMixinsrc/main/java/combatant/client/mixins/EntityMixin.javaJava · 190 lines · 6.9 KB
@Mixin(Entity.class)
ModifiesEntity
EntityMixin.javaJava · 190 lines · 6.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
11
import net.minecraft.client.player.LocalPlayer;
12
import net.minecraft.world.entity.Entity;
13
import net.minecraft.world.entity.MoverType;
14
import net.minecraft.world.level.block.state.BlockState;
15
import net.minecraft.world.phys.Vec3;
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.ModifyVariable;
22
import org.spongepowered.asm.mixin.injection.Redirect;
23
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
24
import combatant.client.events.Events;
25
import combatant.client.events.impl.PlayerMoveEvent;
26
import combatant.client.events.impl.PlayerStepEvent;
27
import combatant.client.events.impl.PlayerStepSuccessEvent;
28
import combatant.client.events.impl.PlayerVelocityStrafe;
29
import combatant.client.features.module.Modules;
30
import combatant.client.features.module.modules.movement.NoPush;
31
import combatant.client.features.module.modules.movement.NoStun;
32
import combatant.client.mixininterface.IEntity;
33
import combatant.client.mixins.accessors.EntityAccessor;
34
import combatant.client.mixins.accessors.EntityInvoker;
35
import combatant.client.render.helpers.TrailPoint;
36
import combatant.client.util.aiming.RotationManager;
37
38
import java.util.ArrayList;
39
import java.util.List;
40
41
@Mixin(Entity.class)
42
public abstract class EntityMixin implements IEntity {
43
44
    @Unique
45
    private final List<TrailPoint> trails = new ArrayList<>();
46
    @Shadow
47
    public double xOld;
48
    @Shadow
49
    public double yOld;
50
    @Shadow
51
    public double zOld;
52
    @Unique
53
    private MoverType combatant$lastMoveType = MoverType.SELF;
54
    @Unique
55
    private Vec3 combatant$stepBeforePos = Vec3.ZERO;
56
    @Unique
57
    private Vec3 combatant$stepRequestedMovement = Vec3.ZERO;
58
59
    @Unique
60
    @Override
61
    public Vec3 get$InstantRenderPos() {
62
        return new Vec3(xOld, yOld, zOld);
63
    }
64
65
    @Unique
66
    @Override
67
    public List<TrailPoint> combatant$getTrails() {
68
        return trails;
69
    }
70
71
    @Inject(method = "move", at = @At("HEAD"))
72
    private void combatant$cacheMoveType(MoverType type, Vec3 movement, CallbackInfo ci) {
73
        combatant$lastMoveType = type;
74
        Entity self = (Entity) (Object) this;
75
        if (self instanceof LocalPlayer) {
76
            combatant$stepBeforePos = self.position();
77
            combatant$stepRequestedMovement = movement;
78
        }
79
    }
80
81
    @ModifyVariable(method = "move", at = @At("HEAD"), argsOnly = true, index = 2)
82
    private Vec3 combatant$onMove(Vec3 movement) {
83
        Entity self = (Entity) (Object) this;
84
        if (!(self instanceof LocalPlayer)) return movement;
85
        if (!Events.BUS.hasListeners(PlayerMoveEvent.class)) return movement;
86
87
        PlayerMoveEvent event = new PlayerMoveEvent(combatant$lastMoveType, movement);
88
        Events.BUS.post(event);
89
        Vec3 out = event.getMovement();
90
        return out != null ? out : movement;
91
    }
92
93
    @Inject(method = "move", at = @At("RETURN"))
94
    private void combatant$onMoveReturn(MoverType type, Vec3 movement, CallbackInfo ci) {
95
        Entity self = (Entity) (Object) this;
96
        if (!(self instanceof LocalPlayer)) return;
97
        if (!Events.BUS.hasListeners(PlayerStepSuccessEvent.class)) return;
98
99
        Vec3 before = combatant$stepBeforePos;
100
        Vec3 after = self.position();
101
        Vec3 requested = combatant$stepRequestedMovement;
102
        double yDelta = after.y - before.y;
103
        double horizontalRequested = Math.hypot(requested.x, requested.z);
104
        if (yDelta <= 0.5 || horizontalRequested <= 1.0E-5) return;
105
106
        Events.BUS.post(new PlayerStepSuccessEvent(after.subtract(before)));
107
    }
108
109
    @ModifyReturnValue(method = "maxUpStep", at = @At("RETURN"))
110
    private float combatant$modifyStepHeight(float original) {
111
        Entity self = (Entity) (Object) this;
112
        if (!(self instanceof LocalPlayer)) return original;
113
        if (!Events.BUS.hasListeners(PlayerStepEvent.class)) return original;
114
115
        PlayerStepEvent event = new PlayerStepEvent(original);
116
        Events.BUS.post(event);
117
        return event.getHeight();
118
    }
119
120
    @Redirect(
121
            method = "moveRelative",
122
            at = @At(
123
                    value = "INVOKE",
124
                    target = "Lnet/minecraft/world/entity/Entity;getInputVector(Lnet/minecraft/world/phys/Vec3;FF)Lnet/minecraft/world/phys/Vec3;"
125
            )
126
    )
127
    private Vec3 combatant$velocityStrafe(Vec3 movementInput, float speed, float yaw) {
128
        Entity self = (Entity) (Object) this;
129
        Vec3 vanilla = EntityInvoker.combatant$movementInputToVelocity(movementInput, speed, yaw);
130
        if (!(self instanceof LocalPlayer)) return vanilla;
131
        if (!Events.BUS.hasListeners(PlayerVelocityStrafe.class)) return vanilla;
132
133
        PlayerVelocityStrafe event = new PlayerVelocityStrafe(movementInput, speed, yaw, vanilla);
134
        Events.BUS.post(event);
135
        return event.getVelocity();
136
    }
137
138
    @ModifyVariable(
139
            method = "calculateViewVector(FF)Lnet/minecraft/world/phys/Vec3;",
140
            at = @At("HEAD"),
141
            ordinal = 0,
142
            argsOnly = true
143
    )
144
    private float combatant$rotationVectorPitch(float pitch) {
145
        if (!((Object) this instanceof LocalPlayer)) {
146
            return pitch;
147
        }
148
149
        return RotationManager.INSTANCE.getCurrentRotation() != null
150
                ? RotationManager.INSTANCE.getCurrentRotation().pitch()
151
                : pitch;
152
    }
153
154
    @Redirect(
155
            method = "push(Lnet/minecraft/world/entity/Entity;)V",
156
            at = @At(
157
                    value = "INVOKE",
158
                    target = "Lnet/minecraft/world/entity/Entity;push(DDD)V"
159
            )
160
    )
161
    private void combatant$cancelEntityPush(Entity instance, double x, double y, double z) {
162
        NoPush noPush = Modules.get(NoPush.class);
163
        if (noPush == null || !noPush.off("players")) {
164
            instance.push(x, y, z);
165
        }
166
    }
167
168
    @Inject(method = "makeStuckInBlock", at = @At("HEAD"), cancellable = true)
169
    private void nostun$cancelSlowMovement(BlockState state, Vec3 multiplier, CallbackInfo ci) {
170
        Entity self = (Entity) (Object) this;
171
        if (!(self instanceof LocalPlayer)) return;
172
173
        NoStun ns = Modules.get(NoStun.class);
174
        if (ns == null || !ns.isEnabled()) return;
175
176
        Vec3 override = ns.getSlowMovementOverride(state, multiplier);
177
        if (override != null && self instanceof EntityAccessor accessor) {
178
            self.resetFallDistance();
179
            accessor.combatant$setMovementMultiplier(override);
180
            ci.cancel();
181
            return;
182
        }
183
184
        if (ns.shouldCancelSlowMovement(state)) {
185
            ci.cancel();
186
        }
187
    }
188
189
}
190
EntityRenderStateTemporalMixinsrc/main/java/combatant/client/mixins/EntityRenderStateTemporalMixin.javaJava · 31 lines · 1.0 KB
@Mixin(EntityRenderState.class)
EntityRenderStateTemporalMixin.javaJava · 31 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.mixininterface.ITemporalMotionRenderState;
11
import combatant.client.render.engine.deferred.DeferredMotionState;
12
import net.minecraft.client.renderer.entity.state.EntityRenderState;
13
import org.jetbrains.annotations.Nullable;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.Unique;
16
17
@Mixin(EntityRenderState.class)
18
public class EntityRenderStateTemporalMixin implements ITemporalMotionRenderState {
19
    @Unique private @Nullable DeferredMotionState combatant$temporalMotionState;
20
21
    @Override
22
    public @Nullable DeferredMotionState combatant$getTemporalMotionState() {
23
        return combatant$temporalMotionState;
24
    }
25
26
    @Override
27
    public void combatant$setTemporalMotionState(@Nullable DeferredMotionState state) {
28
        combatant$temporalMotionState = state;
29
    }
30
}
31
EntityRendererTemporalMixinsrc/main/java/combatant/client/mixins/EntityRendererTemporalMixin.javaJava · 34 lines · 1.4 KB
@Mixin(EntityRenderer.class)
EntityRendererTemporalMixin.javaJava · 34 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.mixininterface.ITemporalMotionRenderState;
11
import combatant.client.render.engine.core.CombatantRenderSystem;
12
import net.minecraft.client.renderer.entity.EntityRenderer;
13
import net.minecraft.client.renderer.entity.state.EntityRenderState;
14
import net.minecraft.world.entity.Entity;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
19
20
@Mixin(EntityRenderer.class)
21
public abstract class EntityRendererTemporalMixin {
22
    @Inject(
23
            method = "createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;",
24
            at = @At("RETURN")
25
    )
26
    private void combatant$captureTemporalMotion(Entity entity, float tickProgress,
27
                                                  CallbackInfoReturnable<EntityRenderState> cir) {
28
        EntityRenderState state = cir.getReturnValue();
29
        if (!(state instanceof ITemporalMotionRenderState temporalState)) return;
30
        temporalState.combatant$setTemporalMotionState(
31
                CombatantRenderSystem.deferredWorld().captureEntityMotion(entity, state));
32
    }
33
}
34
EquipmentLayerRendererMixinsrc/main/java/combatant/client/mixins/EquipmentLayerRendererMixin.javaJava · 80 lines · 4.2 KB
@Mixin(EquipmentLayerRenderer.class)
EquipmentLayerRendererMixin.javaJava · 80 lines · 4.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.vertex.PoseStack;
13
import combatant.client.features.playeranimator.PlayerRigInstance;
14
import combatant.client.features.playeranimator.PlayerRigRenderContext;
15
import combatant.client.features.playeranimator.render.PlayerRigCpuRenderer;
16
import net.minecraft.client.model.HumanoidModel;
17
import net.minecraft.client.model.Model;
18
import net.minecraft.client.renderer.OrderedSubmitNodeCollector;
19
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
20
import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer;
21
import net.minecraft.client.renderer.rendertype.RenderType;
22
import net.minecraft.client.renderer.rendertype.RenderTypes;
23
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
24
import net.minecraft.resources.Identifier;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Redirect;
28
import combatant.client.render.ViewObstructionFadeContext;
29
import combatant.client.render.iris.IrisRuntime;
30
31
@Mixin(EquipmentLayerRenderer.class)
32
public abstract class EquipmentLayerRendererMixin {
33
    @WrapOperation(
34
            method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;II)V",
35
            at = @At(
36
                    value = "INVOKE",
37
                    target = "Lnet/minecraft/client/renderer/OrderedSubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"
38
            )
39
    )
40
    private void combatant$submitRiggedArmor(
41
            OrderedSubmitNodeCollector collector,
42
            Model<?> model,
43
            Object modelState,
44
            PoseStack matrices,
45
            RenderType renderType,
46
            int light,
47
            int overlay,
48
            int tint,
49
            TextureAtlasSprite sprite,
50
            int outlineColor,
51
            ModelFeatureRenderer.CrumblingOverlay crumbling,
52
            Operation<Void> original
53
    ) {
54
        PlayerRigInstance rig = PlayerRigRenderContext.current();
55
        if (rig != null && model instanceof HumanoidModel<?> humanoid
56
                && PlayerRigCpuRenderer.submitArmor(
57
                        collector, humanoid, rig, matrices, renderType, light, overlay, tint, sprite,
58
                        outlineColor, crumbling
59
                )) {
60
            return;
61
        }
62
        original.call(collector, model, modelState, matrices, renderType, light, overlay, tint,
63
                sprite, outlineColor, crumbling);
64
    }
65
66
    @Redirect(
67
            method = "renderLayers(Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/world/item/ItemStack;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;II)V",
68
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;armorCutoutNoCull(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;")
69
    )
70
    private RenderType combatant$useTranslucentArmorWhenViewFaded(Identifier texture) {
71
        if (IrisRuntime.isRenderingShadowPass()) {
72
            return RenderTypes.armorCutoutNoCull(texture);
73
        }
74
        if (ViewObstructionFadeContext.isActive() && ViewObstructionFadeContext.alpha() < 0.99f) {
75
            return RenderTypes.armorTranslucent(texture);
76
        }
77
        return RenderTypes.armorCutoutNoCull(texture);
78
    }
79
}
80
ExperienceBarMixinsrc/main/java/combatant/client/mixins/ExperienceBarMixin.javaJava · 52 lines · 1.9 KB
@Mixin(ExperienceBar.class)
ExperienceBarMixin.javaJava · 52 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.DeltaTracker;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.contextualbar.ExperienceBar;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
19
import combatant.client.runtime.RuntimeGate;
20
21
@Mixin(ExperienceBar.class)
22
public abstract class ExperienceBarMixin {
23
24
    @Inject(method = "extractBackground", at = @At("HEAD"), cancellable = true)
25
    private void combatant$renderXpBar(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
26
        if (!RuntimeGate.canRunHud()) return;
27
        Minecraft mc = Minecraft.getInstance();
28
        if (mc == null || mc.player == null) return;
29
30
        CustomBar bar = CustomBar.get();
31
        if (bar == null) return;
32
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
33
34
        // XP/Locator rendering is owned by GuiMixin; suppress vanilla bar state.
35
        ci.cancel();
36
    }
37
38
    @Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
39
    private void combatant$renderXpAddons(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
40
        if (!RuntimeGate.canRunHud()) return;
41
        Minecraft mc = Minecraft.getInstance();
42
        if (mc == null || mc.player == null) return;
43
44
        CustomBar bar = CustomBar.get();
45
        if (bar == null) return;
46
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
47
48
        ci.cancel();
49
    }
50
}
51
52
FireworkRocketEntityMixinsrc/main/java/combatant/client/mixins/FireworkRocketEntityMixin.javaJava · 75 lines · 2.6 KB
@Mixin(FireworkRocketEntity.class)
FireworkRocketEntityMixin.javaJava · 75 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import net.minecraft.client.Minecraft;
13
import net.minecraft.client.player.LocalPlayer;
14
import net.minecraft.world.entity.LivingEntity;
15
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
16
import net.minecraft.world.phys.Vec3;
17
import org.jspecify.annotations.Nullable;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Shadow;
20
import org.spongepowered.asm.mixin.Unique;
21
import org.spongepowered.asm.mixin.injection.At;
22
import combatant.client.events.Events;
23
import combatant.client.events.impl.FireworkEvent;
24
import combatant.client.util.aiming.RotationManager;
25
import combatant.client.util.aiming.data.Rotation;
26
27
@Mixin(FireworkRocketEntity.class)
28
public abstract class FireworkRocketEntityMixin {
29
30
    @Shadow
31
    @Nullable
32
    private LivingEntity attachedToEntity;
33
34
    @Unique
35
    private static Rotation resolveMoveRotation(LocalPlayer player) {
36
        return RotationManager.INSTANCE.getMovementRotation();
37
    }
38
39
    @WrapOperation(
40
            method = "tick",
41
            at = @At(
42
                    value = "INVOKE",
43
                    target = "Lnet/minecraft/world/entity/LivingEntity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"
44
            )
45
    )
46
    private Vec3 combatant$fireworkMoveRotation(LivingEntity instance, Operation<Vec3> original) {
47
        Minecraft mc = Minecraft.getInstance();
48
        if (mc == null || attachedToEntity != mc.player) {
49
            return original.call(instance);
50
        }
51
52
        return resolveMoveRotation(mc.player).directionVector();
53
    }
54
55
    @WrapOperation(
56
            method = "tick",
57
            at = @At(
58
                    value = "INVOKE",
59
                    target = "Lnet/minecraft/world/entity/LivingEntity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;",
60
                    ordinal = 0
61
            )
62
    )
63
    private Vec3 combatant$fireworkVelocityHook(LivingEntity instance, Operation<Vec3> original) {
64
        Minecraft mc = Minecraft.getInstance();
65
        Vec3 velocity = original.call(instance);
66
        if (mc == null || attachedToEntity != mc.player || !Events.BUS.hasListeners(FireworkEvent.class)) {
67
            return velocity;
68
        }
69
70
        FireworkEvent event = new FireworkEvent(velocity);
71
        Events.BUS.post(event);
72
        return event.getVector();
73
    }
74
}
75
FlowingFluidMixinsrc/main/java/combatant/client/mixins/FlowingFluidMixin.javaJava · 56 lines · 2.2 KB
@Mixin(FlowingFluid.class)
ModifiesFlowingFluid
FlowingFluidMixin.javaJava · 56 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 * Portions derived from ThunderHack Recode, copyright (c) 2023-2024 Pan4ur & 06ED.
5
 * Upstream: https://github.com/Pan4ur/ThunderHack-Recode
6
 *
7
 * Licensed under the GNU General Public License v3.0.
8
 */
9
10
package combatant.client.mixins;
11
12
import net.minecraft.core.BlockPos;
13
import net.minecraft.core.Direction;
14
import net.minecraft.world.level.BlockGetter;
15
import net.minecraft.world.level.material.FlowingFluid;
16
import net.minecraft.world.level.material.FluidState;
17
import net.minecraft.world.phys.Vec3;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Shadow;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
23
import combatant.client.features.module.Modules;
24
import combatant.client.features.module.modules.movement.NoPush;
25
26
import static net.minecraft.world.level.material.FlowingFluid.FALLING;
27
28
@Mixin(FlowingFluid.class)
29
public abstract class FlowingFluidMixin {
30
31
    @Shadow
32
    protected abstract boolean isSolidFace(BlockGetter world, BlockPos pos, Direction direction);
33
34
    @Inject(method = "getFlow", at = @At("HEAD"), cancellable = true)
35
    private void combatant$getVelocity(BlockGetter world, BlockPos pos, FluidState state, CallbackInfoReturnable<Vec3> cir) {
36
        NoPush np = Modules.get(NoPush.class);
37
        if (np == null || !np.liquidsEnabled()) return;
38
39
        double d = 0.0;
40
        double e = 0.0;
41
        BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
42
        Vec3 vec3d = new Vec3(d, 0.0, e);
43
        if (state.getValue(FALLING)) {
44
            for (Direction direction2 : Direction.Plane.HORIZONTAL) {
45
                mutable.setWithOffset(pos, direction2);
46
                if (!this.isSolidFace(world, mutable, direction2) && !this.isSolidFace(world, mutable.above(), direction2)) {
47
                    continue;
48
                }
49
                vec3d = vec3d.normalize().add(0.0, -6.0, 0.0);
50
                break;
51
            }
52
        }
53
        cir.setReturnValue(vec3d.normalize());
54
    }
55
}
56
FogRendererMixinsrc/main/java/combatant/client/mixins/FogRendererMixin.javaJava · 84 lines · 3.2 KB
@Mixin(value = FogRenderer.class, priority = 1200)priority 1200
ModifiesFogRenderer
FogRendererMixin.javaJava · 84 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.multiplayer.ClientLevel;
13
import net.minecraft.client.renderer.fog.FogRenderer;
14
import net.minecraft.world.level.Level;
15
import org.joml.Vector4f;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.ModifyVariable;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.features.module.Modules;
22
import combatant.client.features.module.modules.visuals.WorldTweaks;
23
24
@Mixin(value = FogRenderer.class, priority = 1200)
25
public class FogRendererMixin {
26
27
    @ModifyVariable(
28
            method = "setupFog(Lnet/minecraft/client/Camera;ILnet/minecraft/client/DeltaTracker;FLnet/minecraft/client/multiplayer/ClientLevel;)Lnet/minecraft/client/renderer/fog/FogData;",
29
            at = @At("HEAD"),
30
            argsOnly = true,
31
            index = 2)
32
    private int combatant$disableDistanceFog(int value) {
33
        WorldTweaks module = Modules.get(WorldTweaks.class);
34
        if (module == null || !module.isFogControlEnabled()) return value;
35
        Minecraft mc = Minecraft.getInstance();
36
        ClientLevel world = mc != null ? mc.level : null;
37
        if (world == null) return value;
38
39
        int out = value;
40
41
        if (module.disableDistanceFog()) {
42
            int blocks = Math.max(16, module.getDistanceBlocks());
43
            int chunks = (blocks + 15) / 16;
44
            out = Math.max(out, chunks);
45
        }
46
47
        if (module.disableWeatherFog()
48
                && world.dimension() == Level.OVERWORLD
49
                && (world.getRainLevel(1.0f) > 0.0f
50
                || world.getThunderLevel(1.0f) > 0.0f)) {
51
            int blocks = Math.max(16, module.getWeatherDistanceBlocks());
52
            int chunks = (blocks + 15) / 16;
53
            out = Math.max(out, chunks);
54
        }
55
56
        return out;
57
    }
58
59
    @Inject(
60
            method = "computeFogColor(Lnet/minecraft/client/Camera;FLnet/minecraft/client/multiplayer/ClientLevel;IFLorg/joml/Vector4f;)V",
61
            at = @At("RETURN"),
62
            cancellable = true
63
    )
64
    private void combatant$modifyFogColor(Camera camera,
65
                                          float tickDelta,
66
                                          ClientLevel world,
67
                                          int viewDistance,
68
                                          float skyDarkness,
69
                                          Vector4f color, CallbackInfo ci) {
70
        WorldTweaks module = Modules.get(WorldTweaks.class);
71
        if (module == null || !module.isFogModifyEnabled()) return;
72
73
        int argb = module.getFogColorArgb();
74
        float r = ((argb >> 16) & 0xFF) / 255f;
75
        float g = ((argb >> 8) & 0xFF) / 255f;
76
        float b = (argb & 0xFF) / 255f;
77
        float a = 1.0f;
78
        if (color != null) {
79
            a = color.w;
80
            color.set(r, g, b, a);
81
        }
82
    }
83
}
84
FontManagerMixinsrc/main/java/combatant/client/mixins/FontManagerMixin.javaJava · 49 lines · 1.3 KB
@Mixin(FontManager.class)
ModifiesFontManager
FontManagerMixin.javaJava · 49 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.google.gson.JsonParseException;
11
import net.minecraft.client.gui.font.FontManager;
12
import org.slf4j.Logger;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Redirect;
16
17
@Mixin(FontManager.class)
18
public abstract class FontManagerMixin {
19
20
    @Redirect(
21
            method = "loadResourceStack",
22
            at = @At(
23
                    value = "INVOKE",
24
                    target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V"
25
            )
26
    )
27
    private static void combatant$maybeSuppressFontLoadWarn(
28
            Logger logger,
29
            String format,
30
            Object[] args
31
    ) {
32
        if (args != null && args.length > 0) {
33
            Object last = args[args.length - 1];
34
            if (last instanceof JsonParseException jsonParseException) {
35
                String message = jsonParseException.getMessage();
36
                if (message != null && message.contains("No key providers")) {
37
                    return;
38
                }
39
            }
40
        }
41
42
        logger.warn(format, args);
43
    }
44
}
45
46
47
48
49
GameRendererMixinsrc/main/java/combatant/client/mixins/GameRendererMixin.javaJava · 971 lines · 48.9 KB
@Mixin(GameRenderer.class)
ModifiesGameRenderer
GameRendererMixin.javaJava · 971 lines · 48.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.buffers.GpuBufferSlice;
13
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
14
import com.mojang.blaze3d.vertex.PoseStack;
15
import combatant.client.features.gui.preview.VisualPreviewRuntime;
16
import combatant.client.features.module.modules.visuals.*;
17
import combatant.client.render.engine.postprocess.PostProcessPass;
18
import combatant.client.util.screen.ClientScreen;
19
import net.minecraft.client.Camera;
20
import net.minecraft.client.DeltaTracker;
21
import net.minecraft.client.Minecraft;
22
import net.minecraft.client.player.AbstractClientPlayer;
23
import net.minecraft.client.player.LocalPlayer;
24
import net.minecraft.client.renderer.GameRenderer;
25
import net.minecraft.client.renderer.LevelRenderer;
26
import net.minecraft.client.renderer.ProjectionMatrixBuffer;
27
import net.minecraft.client.renderer.SubmitNodeStorage;
28
import net.minecraft.client.renderer.culling.Frustum;
29
import net.minecraft.client.renderer.feature.FeatureRenderDispatcher;
30
import net.minecraft.client.renderer.state.GameRenderState;
31
import net.minecraft.client.renderer.state.level.CameraRenderState;
32
import net.minecraft.util.Mth;
33
import net.minecraft.world.effect.MobEffects;
34
import net.minecraft.world.level.material.FogType;
35
import net.minecraft.world.phys.Vec3;
36
import org.joml.Matrix4f;
37
import org.joml.Matrix4fc;
38
import org.joml.Vector3f;
39
import org.joml.Vector4f;
40
import org.spongepowered.asm.mixin.Final;
41
import org.spongepowered.asm.mixin.Mixin;
42
import org.spongepowered.asm.mixin.Shadow;
43
import org.spongepowered.asm.mixin.Unique;
44
import org.spongepowered.asm.mixin.injection.At;
45
import org.spongepowered.asm.mixin.injection.Inject;
46
import org.spongepowered.asm.mixin.injection.Redirect;
47
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
48
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
49
import combatant.client.features.gui.clickgui.ClickGuiRenderer;
50
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
51
import combatant.client.features.gui.hud.nondraggable.impl.BetterTooltips;
52
import combatant.client.addon.AddonRenderPipelineManager;
53
import combatant.client.api.v0.render.CombatantRenderStage;
54
import combatant.client.features.module.ModuleManager;
55
import combatant.client.features.module.Modules;
56
import combatant.client.features.module.WorldPhase;
57
import combatant.client.features.module.modules.visuals.*;
58
import combatant.client.mixins.accessors.GameRendererAccessor;
59
import combatant.client.mixins.accessors.LocalPlayerAccessor;
60
import combatant.client.render.engine.RenderState;
61
import combatant.client.render.engine.core.CombatantRenderSystem;
62
import combatant.client.render.engine.core.CombatantWorldMatrices;
63
import combatant.client.render.engine.core.RenderPhase;
64
import combatant.client.render.engine.core.RenderPhaseScope;
65
import combatant.client.render.engine.depth.WorldSceneDepth;
66
import combatant.client.render.engine.deferred.DeferredJitterSequence;
67
import combatant.client.render.engine.deferred.DeferredFeature;
68
import combatant.client.render.engine.deferred.DeferredRuntimeConfig;
69
import combatant.client.render.engine.rhi.shader.RhiShaderStage;
70
import combatant.client.render.engine.debug.UiClipDebugScene;
71
import combatant.client.render.engine.msaa.MsaaWorldTarget;
72
import combatant.client.config.MainConfig;
73
import combatant.client.render.engine.pipeline.CombatantRenderPipelines;
74
import combatant.client.render.engine.postprocess.PostProcessManager;
75
import combatant.client.render.engine.postprocess.MenuBackgroundRenderer;
76
import combatant.client.render.engine.profiler.ProfilerPhase;
77
import combatant.client.render.engine.profiler.RenderProfiler3D;
78
import combatant.client.render.engine.profiler.TracyGpuProfiler;
79
import combatant.client.render.engine.renderer.MeshRenderer;
80
import combatant.client.render.engine.renderer.Renderer2D;
81
import combatant.client.render.engine.renderer.ui.UiBlurResources;
82
import combatant.client.render.engine.renderer.Renderer3D;
83
import combatant.client.render.engine.text.TextRenderer;
84
import combatant.client.render.iris.IrisCombatantFrameHooks;
85
import combatant.client.render.iris.IrisFinalizedSceneRenderer;
86
import combatant.client.render.iris.IrisCompatibilityGuards;
87
import combatant.client.render.iris.IrisRuntime;
88
import combatant.client.util.logging.DebugLog;
89
90
@Mixin(GameRenderer.class)
91
public abstract class GameRendererMixin implements IrisFinalizedSceneRenderer {
92
93
    @Unique
94
    private static final boolean COMBATANT_DEBUG_PRIMITIVE = false;
95
    @Unique
96
    private static final boolean COMBATANT_DEBUG_CLIP_SPACE = false;
97
    @Unique
98
    private static final long COMBATANT_DEBUG_INTERVAL_MS = 2000L;
99
    @Unique
100
    private static long COMBATANT_DEBUG_LAST_MS;
101
    @Unique
102
    private final PoseStack combatant$matrices = new PoseStack();
103
    @Unique
104
    private final PoseStack combatant$postMatrices = new PoseStack();
105
    @Shadow
106
    @Final
107
    private Minecraft minecraft;
108
    @Shadow
109
    @Final
110
    private Camera mainCamera;
111
    @Shadow
112
    @Final
113
    private GameRenderState gameRenderState;
114
    @Shadow
115
    private float spinningEffectTime;
116
    @Shadow
117
    private float spinningEffectSpeed;
118
    @Unique
119
    private Renderer3D combatant$renderer;
120
    @Unique
121
    private Renderer3D combatant$depthRenderer;
122
    @Unique
123
    private Renderer3D combatant$postRenderer;
124
    @Unique
125
    private Renderer3D combatant$postDepthRenderer;
126
127
    @Unique
128
    private static void combatant$drawDebugCube(Renderer3D rdr,
129
                                                double x1, double y1, double z1,
130
                                                double x2, double y2, double z2) {
131
        rdr.line(x1, y1, z1, x2, y1, z1, 255, 0, 0, 255);
132
        rdr.line(x1, y2, z1, x2, y2, z1, 255, 0, 0, 255);
133
        rdr.line(x1, y1, z2, x2, y1, z2, 255, 0, 0, 255);
134
        rdr.line(x1, y2, z2, x2, y2, z2, 255, 0, 0, 255);
135
136
        rdr.line(x1, y1, z1, x1, y2, z1, 0, 255, 0, 255);
137
        rdr.line(x2, y1, z1, x2, y2, z1, 0, 255, 0, 255);
138
        rdr.line(x1, y1, z2, x1, y2, z2, 0, 255, 0, 255);
139
        rdr.line(x2, y1, z2, x2, y2, z2, 0, 255, 0, 255);
140
141
        rdr.line(x1, y1, z1, x1, y1, z2, 0, 0, 255, 255);
142
        rdr.line(x2, y1, z1, x2, y1, z2, 0, 0, 255, 255);
143
        rdr.line(x1, y2, z1, x1, y2, z2, 0, 0, 255, 255);
144
        rdr.line(x2, y2, z1, x2, y2, z2, 0, 0, 255, 255);
145
    }
146
147
    @Unique
148
    private static boolean isWorldTranslucent(FogType type) {
149
        return type == FogType.WATER
150
                || type == FogType.LAVA
151
                || type == FogType.POWDER_SNOW;
152
    }
153
154
    @Shadow
155
    protected abstract void bobView(CameraRenderState cameraRenderState, PoseStack matrices);
156
157
    @Shadow
158
    protected abstract void bobHurt(CameraRenderState cameraRenderState, PoseStack matrices);
159
160
    @Unique
161
    private static boolean combatant$needsResolvedMainDepth() {
162
        // Legacy ReimaginedVisual DoF depth capture is retired. Deferred camera post consumes
163
        // FINAL_RESOLVED_DEPTH through the typed frame-graph contract instead.
164
        return false;
165
    }
166
167
    @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
168
    private void combatant$skipTickWithoutPlayer(CallbackInfo ci) {
169
        if (minecraft != null && minecraft.level != null && minecraft.player == null) {
170
            ci.cancel();
171
        }
172
    }
173
174
    @Inject(method = "extract(Lnet/minecraft/client/DeltaTracker;Z)V", at = @At("HEAD"))
175
    private void combatant$beginDeferred2DExtract(DeltaTracker tickCounter, boolean tick, CallbackInfo ci) {
176
        Renderer2D.beginDeferredExtractFrame();
177
    }
178
179
    @Inject(method = "extract(Lnet/minecraft/client/DeltaTracker;Z)V", at = @At("TAIL"))
180
    private void combatant$endDeferred2DExtract(DeltaTracker tickCounter, boolean tick, CallbackInfo ci) {
181
        Renderer2D.endDeferredExtractFrame();
182
    }
183
184
    @Redirect(
185
            method = "renderItemInHand(Lnet/minecraft/client/renderer/state/level/CameraRenderState;FLorg/joml/Matrix4fc;)V",
186
            at = @At(
187
                    value = "INVOKE",
188
                    target = "Lnet/minecraft/client/renderer/GameRenderer;bobView(Lnet/minecraft/client/renderer/state/level/CameraRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;)V"
189
            )
190
    )
191
    private void combatant$viewModel$replaceHandBobbing(GameRenderer instance,
192
                                                        CameraRenderState cameraRenderState,
193
                                                        PoseStack matrices,
194
                                                        CameraRenderState originalCameraRenderState,
195
                                                        float tickDelta,
196
                                                        Matrix4fc positionMatrix) {
197
        ViewModel viewModel = Modules.get(ViewModel.class);
198
        if (viewModel != null && viewModel.smoothRunLoweringEnabled()) {
199
            if (minecraft != null && minecraft.getCameraEntity() instanceof AbstractClientPlayer player) {
200
                float movement = player.avatarState().getInterpolatedBob(tickDelta);
201
                float yOffset = -Mth.clamp(movement, 0.0f, 1.0f) * viewModel.getSmoothRunLoweringAmount();
202
                if (Math.abs(yOffset) > 0.0001f) {
203
                    matrices.translate(0.0f, yOffset, 0.0f);
204
                }
205
            }
206
            return;
207
        }
208
209
        ((GameRendererAccessor) instance).invokeBobView(cameraRenderState, matrices);
210
    }
211
212
    @Inject(method = "extractCamera", at = @At("TAIL"))
213
    private void combatant$modifyAspect(DeltaTracker tickCounter, float tickDelta, float fov, CallbackInfo ci) {
214
215
        AspectRatio ar = Modules.get(AspectRatio.class);
216
        if (ar == null || !ar.isEnabled()) {
217
            return;
218
        }
219
220
        float mul = ar.getMultiplier();
221
        if (mul == 1.0f) {
222
            return;
223
        }
224
225
        Matrix4f m = gameRenderState.levelRenderState.cameraRenderState.projectionMatrix;
226
        if (m == null) return;
227
228
        // horizontal aspect stretch
229
        m.m00(m.m00() * mul);
230
    }
231
232
    @Inject(method = "extractCamera", at = @At("TAIL"))
233
    private void combatant$captureProjectionFor2DOverlays(DeltaTracker tickCounter, float tickDelta, float fov, CallbackInfo ci) {
234
        if (gameRenderState == null || gameRenderState.levelRenderState == null) return;
235
        CameraRenderState cameraRenderState = gameRenderState.levelRenderState.cameraRenderState;
236
        if (cameraRenderState == null || cameraRenderState.viewRotationMatrix == null || cameraRenderState.projectionMatrix == null) return;
237
238
        PoseStack effectMatrices = new PoseStack();
239
        Matrix4f renderProjection = combatant$buildWorldProjection(fov, effectMatrices, tickDelta);
240
        AspectRatio.applyToProjection(renderProjection);
241
        Matrix4f screenProjection = new Matrix4f(cameraRenderState.projectionMatrix);
242
        CombatantWorldMatrices.capture(
243
                cameraRenderState.viewRotationMatrix,
244
                renderProjection,
245
                screenProjection,
246
                cameraRenderState.pos != null ? cameraRenderState.pos : mainCamera.position()
247
        );
248
    }
249
250
    @Inject(method = "mainRenderTarget", at = @At("HEAD"), cancellable = true)
251
    private void combatant$overrideWorldFramebuffer(CallbackInfoReturnable<com.mojang.blaze3d.pipeline.RenderTarget> cir) {
252
        com.mojang.blaze3d.pipeline.RenderTarget msaa = MsaaWorldTarget.getFramebufferOverride();
253
        if (msaa != null) {
254
            cir.setReturnValue(msaa);
255
        }
256
    }
257
258
    @Unique
259
    private void combatant$renderWorldEngine(DeltaTracker tickCounter) {
260
        try (ProfilerPhase.Scope phaseScope = ProfilerPhase.scope("3d:world");
261
             TracyGpuProfiler.Scope gpuScope = TracyGpuProfiler.beginZone("3d:world")) {
262
            float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
263
            float fov = mainCamera.getFov();
264
            Matrix4f capturedPosition = CombatantWorldMatrices.positionMatrix();
265
            Matrix4f capturedProjection = CombatantWorldMatrices.renderProjectionMatrix();
266
            boolean useCapturedMatrices = capturedPosition != null && capturedProjection != null;
267
            Matrix4f position = useCapturedMatrices
268
                    ? capturedPosition
269
                    : new Matrix4f().rotation(mainCamera.rotation().conjugate(new org.joml.Quaternionf()));
270
            RenderState.rendering3D = true;
271
            Vec3 capturedCameraPos = CombatantWorldMatrices.cameraPosition();
272
            RenderState.cameraPos = capturedCameraPos != null ? capturedCameraPos : mainCamera.position();
273
            RenderState.cameraRotation.set(mainCamera.rotation());
274
            RenderState.cameraYaw = mainCamera.yRot();
275
            RenderState.cameraPitch = mainCamera.xRot();
276
            RenderState.cameraLook = Vec3.directionFromRotation(RenderState.cameraPitch, RenderState.cameraYaw).normalize();
277
            RenderState.cameraSubmersion = mainCamera.getFluidInCamera();
278
            RenderState.worldTranslucent = isWorldTranslucent(RenderState.cameraSubmersion);
279
            RenderState.frustum = mainCamera != null
280
                    ? mainCamera.getCapturedFrustum()
281
                    : null;
282
283
            if (COMBATANT_DEBUG_CLIP_SPACE) {
284
                var mv = com.mojang.blaze3d.systems.RenderSystem.getModelViewStack();
285
                mv.pushMatrix();
286
                mv.identity();
287
288
                MeshRenderer.setProjection(new Matrix4f().identity());
289
                RenderState.rendering3D = false;
290
291
                if (combatant$renderer == null) {
292
                    combatant$renderer = new Renderer3D(
293
                            CombatantRenderPipelines.WORLD_COLORED_LINES,
294
                            CombatantRenderPipelines.WORLD_COLORED
295
                    );
296
                }
297
298
                combatant$renderer.begin();
299
300
                // Clip-space square + diagonals (NDC)
301
                combatant$renderer.line(-0.8, -0.8, 0.0, 0.8, -0.8, 0.0, 255, 0, 0, 255);
302
                combatant$renderer.line(0.8, -0.8, 0.0, 0.8, 0.8, 0.0, 0, 255, 0, 255);
303
                combatant$renderer.line(0.8, 0.8, 0.0, -0.8, 0.8, 0.0, 0, 0, 255, 255);
304
                combatant$renderer.line(-0.8, 0.8, 0.0, -0.8, -0.8, 0.0, 255, 255, 0, 255);
305
                combatant$renderer.line(-0.8, -0.8, 0.0, 0.8, 0.8, 0.0, 255, 0, 255, 255);
306
                combatant$renderer.line(0.8, -0.8, 0.0, -0.8, 0.8, 0.0, 0, 255, 255, 255);
307
308
                combatant$renderer.render(new PoseStack());
309
310
                mv.popMatrix();
311
                RenderState.rendering3D = false;
312
                return;
313
            }
314
315
            if (combatant$renderer == null) {
316
                combatant$renderer = new Renderer3D(
317
                        CombatantRenderPipelines.WORLD_COLORED_LINES,
318
                        CombatantRenderPipelines.WORLD_COLORED
319
                );
320
            }
321
322
            if (combatant$depthRenderer == null) {
323
                combatant$depthRenderer = new Renderer3D(
324
                        CombatantRenderPipelines.WORLD_COLORED_LINES_DEPTH,
325
                        CombatantRenderPipelines.WORLD_COLORED_DEPTH
326
                );
327
            }
328
329
            var mv = com.mojang.blaze3d.systems.RenderSystem.getModelViewStack();
330
            mv.pushMatrix();
331
            if (IrisCombatantFrameHooks.isRenderingAfterIrisFinalization()) {
332
                mv.identity();
333
            }
334
            mv.mul(position);
335
            combatant$matrices.pushPose();
336
            Matrix4f projection = useCapturedMatrices
337
                    ? capturedProjection
338
                    : combatant$buildWorldProjection(fov, combatant$matrices, tickDelta);
339
            MeshRenderer.setProjection(projection);
340
            CombatantRenderSystem.beginFrame(
341
                    tickDelta,
342
                    tickCounter.getGameTimeDeltaTicks(),
343
                    tickCounter.getRealtimeDeltaTicks(),
344
                    projection,
345
                    new Matrix4f(mv)
346
            );
347
            try (RenderPhaseScope combatant$beforeTranslucentPhase = CombatantRenderSystem.phase(RenderPhase.WORLD_BEFORE_TRANSLUCENT)) {
348
                RenderState.worldProjection.set(projection);
349
                RenderState.frustum = new Frustum(position, projection);
350
                RenderState.frustum.prepare(RenderState.cameraPos.x, RenderState.cameraPos.y, RenderState.cameraPos.z);
351
352
                if (!useCapturedMatrices) {
353
                    Matrix4f inverseBob = new Matrix4f(combatant$matrices.last().pose()).invert();
354
                    mv.mul(inverseBob);
355
                }
356
357
                combatant$renderer.begin();
358
                combatant$depthRenderer.begin();
359
360
                if (COMBATANT_DEBUG_PRIMITIVE) {
361
                    Vec3 camPos = mainCamera.position();
362
                    float yaw = mainCamera.yRot() * ((float) Math.PI / 180.0f);
363
                    float pitch = mainCamera.xRot() * ((float) Math.PI / 180.0f);
364
                    Vec3 forward = new Vec3(
365
                            -Mth.sin(yaw) * Mth.cos(pitch),
366
                            -Mth.sin(pitch),
367
                            Mth.cos(yaw) * Mth.cos(pitch)
368
                    );
369
370
                    Vec3 center = camPos.add(forward.scale(3.0));
371
                    double r = 0.5;
372
                    double x1 = center.x - r, x2 = center.x + r;
373
                    double y1 = center.y - r, y2 = center.y + r;
374
                    double z1 = center.z - r, z2 = center.z + r;
375
                    double ox1 = -1.0, oy1 = -1.0, oz1 = -1.0;
376
                    double ox2 = 1.0, oy2 = 1.0, oz2 = 1.0;
377
378
                    // Wire cube (no depth) and depth variant
379
                    Renderer3D[] targets = new Renderer3D[]{combatant$renderer, combatant$depthRenderer};
380
                    for (Renderer3D rdr : targets) {
381
                        combatant$drawDebugCube(rdr, x1, y1, z1, x2, y2, z2);
382
                        combatant$drawDebugCube(rdr, ox1, oy1, oz1, ox2, oy2, oz2);
383
                    }
384
385
                    long now = System.currentTimeMillis();
386
                    if (now - COMBATANT_DEBUG_LAST_MS >= COMBATANT_DEBUG_INTERVAL_MS) {
387
                        COMBATANT_DEBUG_LAST_MS = now;
388
                        Matrix4f mvMat = com.mojang.blaze3d.systems.RenderSystem.getModelViewMatrixCopy();
389
                        DebugLog.renderThread(
390
                                "[Combatant] Debug diag: cam=" + camPos
391
                                        + " proj=[" + projection.m00() + "," + projection.m11() + "," + projection.m22() + "," + projection.m33() + "]"
392
                                        + " mv=[" + mvMat.m30() + "," + mvMat.m31() + "," + mvMat.m32() + "]"
393
                        );
394
                    }
395
                }
396
397
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:modules_before_translucent");
398
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("modules_before_translucent")) {
399
                    ModuleManager.renderWorldEngine(WorldPhase.BEFORE_TRANSLUCENT, combatant$renderer, combatant$depthRenderer, tickDelta);
400
                    AddonRenderPipelineManager.render3D(CombatantRenderStage.WORLD_BEFORE_TRANSLUCENT,
401
                            WorldPhase.BEFORE_TRANSLUCENT, combatant$renderer, combatant$depthRenderer, combatant$matrices, tickDelta);
402
                }
403
404
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:flush_before_translucent");
405
                     TracyGpuProfiler.Scope gpuFlush = TracyGpuProfiler.beginZone("3d:flush_before_translucent");
406
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("flush_before_translucent")) {
407
                    combatant$renderer.render(combatant$matrices);
408
                    combatant$depthRenderer.render(combatant$matrices);
409
                }
410
            }
411
412
            // Start a new batch for END_MAIN so overlays render above grass.
413
            combatant$renderer.begin();
414
            combatant$depthRenderer.begin();
415
416
            try (RenderPhaseScope combatant$afterTranslucentPhase = CombatantRenderSystem.phase(RenderPhase.WORLD_AFTER_TRANSLUCENT)) {
417
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:modules_end_main");
418
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("modules_end_main")) {
419
                    ModuleManager.renderWorldEngine(WorldPhase.END_MAIN, combatant$renderer, combatant$depthRenderer, tickDelta);
420
                    AddonRenderPipelineManager.render3D(CombatantRenderStage.WORLD_END_MAIN,
421
                            WorldPhase.END_MAIN, combatant$renderer, combatant$depthRenderer, combatant$matrices, tickDelta);
422
423
                    // Keep world billboards in the same END_MAIN world stage, but record them
424
                    // after ordinary translucent effects/particles. Billboard primitives use
425
                    // DepthMode.NONE, so the final ordering is deterministic without moving
426
                    // them into a HUD/post-process layer.
427
                    ModuleManager.renderWorldEngine(WorldPhase.END_MAIN_BILLBOARD,
428
                            combatant$renderer, combatant$depthRenderer, tickDelta);
429
                }
430
431
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:flush_end_main");
432
                     TracyGpuProfiler.Scope gpuFlush = TracyGpuProfiler.beginZone("3d:flush_end_main");
433
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("flush_end_main")) {
434
                    combatant$renderer.render(combatant$matrices);
435
                    combatant$depthRenderer.render(combatant$matrices);
436
                }
437
            }
438
            combatant$matrices.popPose();
439
            mv.popMatrix();
440
            RenderState.rendering3D = false;
441
        }
442
    }
443
444
445
    @Inject(method = "renderLevel", at = @At("HEAD"))
446
    private void combatant$beginWorldMsaa(DeltaTracker tickCounter, CallbackInfo ci) {
447
        CombatantWorldMatrices.reset();
448
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
449
        IrisCombatantFrameHooks.beginRenderLevel(tickCounter);
450
        int samples = MainConfig.get().getMsaa3dSamples();
451
        MsaaWorldTarget.begin(minecraft, samples, combatant$needsResolvedMainDepth());
452
    }
453
454
    @Inject(method = "renderLevel", at = @At("RETURN"))
455
    private void combatant$endIrisFrameHooks(DeltaTracker tickCounter, CallbackInfo ci) {
456
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
457
        IrisCombatantFrameHooks.endRenderLevel(tickCounter);
458
    }
459
460
    @Redirect(
461
            method = "renderLevel",
462
            at = @At(
463
                    value = "INVOKE",
464
                    target = "Lnet/minecraft/client/renderer/LevelRenderer;render(Lcom/mojang/blaze3d/resource/GraphicsResourceAllocator;Lnet/minecraft/client/DeltaTracker;ZLnet/minecraft/client/renderer/state/level/CameraRenderState;Lorg/joml/Matrix4fc;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Lorg/joml/Vector4f;Z)V"
465
            )
466
    )
467
    private void combatant$skipWorldForVisualPreview(LevelRenderer renderer,
468
                                                      GraphicsResourceAllocator resources,
469
                                                      DeltaTracker tickCounter,
470
                                                      boolean renderBlockOutline,
471
                                                      CameraRenderState camera,
472
                                                      Matrix4fc positionMatrix,
473
                                                      GpuBufferSlice fog,
474
                                                      Vector4f clearColor,
475
                                                      boolean renderSky) {
476
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
477
        renderer.render(resources, tickCounter, renderBlockOutline, camera, positionMatrix, fog, clearColor, renderSky);
478
    }
479
480
    @WrapOperation(
481
            method = "renderLevel",
482
            at = @At(
483
                    value = "INVOKE",
484
                    target = "Lnet/minecraft/client/renderer/ProjectionMatrixBuffer;getBuffer(Lorg/joml/Matrix4f;)Lcom/mojang/blaze3d/buffers/GpuBufferSlice;"
485
            )
486
    )
487
    private GpuBufferSlice combatant$captureFullWorldMatrices(ProjectionMatrixBuffer instance,
488
                                                               Matrix4f renderProjectionMatrix,
489
                                                               Operation<GpuBufferSlice> original) {
490
        if (renderProjectionMatrix != null
491
                && gameRenderState != null
492
                && gameRenderState.levelRenderState != null
493
                && gameRenderState.levelRenderState.cameraRenderState != null
494
                && gameRenderState.levelRenderState.cameraRenderState.viewRotationMatrix != null
495
                && gameRenderState.levelRenderState.cameraRenderState.projectionMatrix != null) {
496
            CameraRenderState cameraRenderState = gameRenderState.levelRenderState.cameraRenderState;
497
            Vec3 cameraPosition = cameraRenderState.pos != null ? cameraRenderState.pos : mainCamera.position();
498
499
            // Open/refresh the Combatant frame first so the jitter sample is keyed to the canonical
500
            // frame id. The second beginFrame call below only refreshes CameraContext; it never
501
            // advances frameId while the frame is already open.
502
            DeltaTracker tickCounter = minecraft.getDeltaTracker();
503
            float tickProgress = tickCounter != null
504
                    ? tickCounter.getGameTimeDeltaPartialTick(true) : RenderState.tickProgress;
505
            float frameDeltaTicks = tickCounter != null
506
                    ? tickCounter.getGameTimeDeltaTicks() : RenderState.frameDeltaTicks;
507
            float fixedDeltaTicks = tickCounter != null
508
                    ? tickCounter.getRealtimeDeltaTicks() : RenderState.fixedDeltaTicks;
509
            var frame = CombatantRenderSystem.beginFrame(
510
                    tickProgress,
511
                    frameDeltaTicks,
512
                    fixedDeltaTicks,
513
                    renderProjectionMatrix,
514
                    new Matrix4f(cameraRenderState.viewRotationMatrix)
515
            );
516
517
            Matrix4f unjitteredProjection = new Matrix4f(renderProjectionMatrix);
518
            Matrix4f jitteredProjection = unjitteredProjection;
519
            org.joml.Vector2f jitterPixels = new org.joml.Vector2f();
520
            if (CombatantRenderSystem.deferredWorld().enabled()
521
                    && CombatantRenderSystem.deferredWorld().smokeTestState()
522
                    .featureEnabled(DeferredFeature.TAA, DeferredRuntimeConfig.current())
523
                    && CombatantRenderSystem.rhi().advancedShaders().supports(RhiShaderStage.COMPUTE)) {
524
                var mainTarget = minecraft.gameRenderer.mainRenderTarget();
525
                var colorView = mainTarget != null ? mainTarget.getColorTextureView() : null;
526
                int renderWidth = colorView != null ? Math.max(1, colorView.getWidth(0))
527
                        : Math.max(1, minecraft.getWindow().getWidth());
528
                int renderHeight = colorView != null ? Math.max(1, colorView.getHeight(0))
529
                        : Math.max(1, minecraft.getWindow().getHeight());
530
                jitterPixels = DeferredJitterSequence.sample(frame.frameId());
531
                jitteredProjection = DeferredJitterSequence.apply(
532
                        unjitteredProjection, jitterPixels, renderWidth, renderHeight
533
                );
534
                frame = CombatantRenderSystem.beginFrame(
535
                        tickProgress, frameDeltaTicks, fixedDeltaTicks, jitteredProjection,
536
                        new Matrix4f(cameraRenderState.viewRotationMatrix)
537
                );
538
            }
539
540
            CombatantWorldMatrices.capture(
541
                    cameraRenderState.viewRotationMatrix,
542
                    jitteredProjection,
543
                    unjitteredProjection,
544
                    cameraRenderState.projectionMatrix,
545
                    jitterPixels,
546
                    cameraPosition
547
            );
548
            CombatantRenderSystem.deferredWorld().capturePrimaryView(
549
                    frame.frameId(),
550
                    cameraRenderState.viewRotationMatrix,
551
                    jitteredProjection,
552
                    unjitteredProjection,
553
                    jitterPixels,
554
                    cameraPosition,
555
                    cameraRenderState.depthFar
556
            );
557
            return original.call(instance, jitteredProjection);
558
        }
559
        return original.call(instance, renderProjectionMatrix);
560
    }
561
562
    @Inject(
563
            method = "renderLevel",
564
            at = @At(
565
                    value = "INVOKE_STRING",
566
                    target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V",
567
                    args = "ldc=hand",
568
                    shift = At.Shift.AFTER
569
            )
570
    )
571
    private void combatant$postProcess(DeltaTracker tickCounter, CallbackInfo ci) {
572
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
573
        if (IrisRuntime.isShaderpackRendererActive()
574
                && IrisCompatibilityGuards.deferIrisFinalizationForSecondHandScene()) {
575
            return;
576
        }
577
        combatant$renderPreHandPostProcess(tickCounter);
578
    }
579
580
    @Unique
581
    private void combatant$renderPreHandPostProcess(DeltaTracker tickCounter) {
582
        try (ProfilerPhase.Scope profilerScope = ProfilerPhase.scope("3d:post_pre_hand");
583
            TracyGpuProfiler.Scope gpuScope = TracyGpuProfiler.beginZone("3d:post_pre_hand")) {
584
            if (minecraft != null) {
585
                try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("3d:pre_hand_resolve");
586
                     TracyGpuProfiler.Scope ignoredGpu = TracyGpuProfiler.beginZone("3d:pre_hand:resolve")) {
587
                    boolean needsResolvedDepth = !IrisRuntime.isShaderpackRendererActive()
588
                            && combatant$needsResolvedMainDepth();
589
                    boolean capturedMsaaDepth = needsResolvedDepth
590
                            && MsaaWorldTarget.isActive()
591
                            && WorldSceneDepth.captureResolvedMain(MsaaWorldTarget.getMsaaFramebuffer());
592
                    MsaaWorldTarget.resolveToMain(minecraft);
593
                    if (needsResolvedDepth && !capturedMsaaDepth) {
594
                        WorldSceneDepth.captureResolvedMain(minecraft.gameRenderer.mainRenderTarget());
595
                    }
596
                }
597
                com.mojang.blaze3d.pipeline.RenderTarget resolvedMain = minecraft.gameRenderer.mainRenderTarget();
598
                com.mojang.blaze3d.textures.GpuTextureView resolvedDepth = WorldSceneDepth.hasMain()
599
                        ? WorldSceneDepth.mainDepthView()
600
                        : resolvedMain.getDepthTextureView();
601
                CombatantRenderSystem.deferredWorld().beforePostProcess(
602
                        resolvedMain.getColorTextureView(), resolvedDepth
603
                );
604
            }
605
            try (RenderPhaseScope combatant$postPreHandPhase = CombatantRenderSystem.phase(RenderPhase.WORLD_POST_PRE_HAND)) {
606
                PostProcessManager.renderAll(PostProcessPass.Phase.PRE_HAND,
607
                        tickCounter.getGameTimeDeltaPartialTick(true));
608
                com.mojang.blaze3d.pipeline.RenderTarget resolvedMain = minecraft != null
609
                        ? minecraft.gameRenderer.mainRenderTarget() : null;
610
                if (resolvedMain != null) {
611
                    com.mojang.blaze3d.textures.GpuTextureView resolvedDepth = WorldSceneDepth.hasMain()
612
                            ? WorldSceneDepth.mainDepthView()
613
                            : resolvedMain.getDepthTextureView();
614
                    CombatantRenderSystem.deferredWorld().afterPostProcess(
615
                            resolvedMain.getColorTextureView(), resolvedDepth
616
                    );
617
                }
618
                combatant$renderCombatantWorldAfterPreHandPostProcess(tickCounter);
619
            }
620
        }
621
    }
622
623
    @Unique
624
    private void combatant$renderCombatantWorldAfterPreHandPostProcess(DeltaTracker tickCounter) {
625
        if (minecraft == null) {
626
            combatant$renderWorldEngine(tickCounter);
627
            combatant$renderPostProcessWorld(tickCounter);
628
            return;
629
        }
630
631
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("3d:world_engine_target");
632
             TracyGpuProfiler.Scope ignoredGpu = TracyGpuProfiler.beginZone("3d:world_engine_target")) {
633
            MsaaWorldTarget.begin(minecraft, MainConfig.get().getMsaa3dSamples(), false, true);
634
            try {
635
                combatant$renderWorldEngine(tickCounter);
636
                combatant$renderPostProcessWorld(tickCounter);
637
            } finally {
638
                MsaaWorldTarget.resolveToMain(minecraft);
639
            }
640
        }
641
    }
642
643
    @Override
644
    public void combatant$renderAfterIrisFinalization(DeltaTracker tickCounter) {
645
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
646
        combatant$renderPreHandPostProcess(tickCounter);
647
    }
648
649
    @Inject(
650
            method = "renderLevel",
651
            at = @At(
652
                    value = "INVOKE",
653
                    target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher;renderAllFeatures(Lnet/minecraft/client/renderer/SubmitNodeStorage;)V",
654
                    shift = At.Shift.AFTER
655
            )
656
    )
657
    private void combatant$postProcessAfterHand(DeltaTracker tickCounter, CallbackInfo ci) {
658
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) return;
659
        try (ProfilerPhase.Scope profilerScope = ProfilerPhase.scope("3d:post_after_hand");
660
             TracyGpuProfiler.Scope gpuScope = TracyGpuProfiler.beginZone("3d:post_after_hand")) {
661
            if (minecraft != null) {
662
                MsaaWorldTarget.resolveToMain(minecraft);
663
            }
664
            try (RenderPhaseScope combatant$postHandPhase = CombatantRenderSystem.phase(RenderPhase.WORLD_POST_HAND)) {
665
                PostProcessManager.renderAll(PostProcessPass.Phase.POST_HAND,
666
                        tickCounter.getGameTimeDeltaPartialTick(true));
667
                if (minecraft != null) {
668
                    com.mojang.blaze3d.pipeline.RenderTarget resolvedMain = minecraft.gameRenderer.mainRenderTarget();
669
                    com.mojang.blaze3d.textures.GpuTextureView resolvedDepth = WorldSceneDepth.hasMain()
670
                            ? WorldSceneDepth.mainDepthView()
671
                            : resolvedMain.getDepthTextureView();
672
                    CombatantRenderSystem.deferredWorld().finalComposite(
673
                            resolvedMain.getColorTextureView(), resolvedDepth
674
                    );
675
                }
676
            }
677
        }
678
    }
679
680
    @Unique
681
    private void combatant$renderPostProcessWorld(DeltaTracker tickCounter) {
682
        try (ProfilerPhase.Scope phaseScope = ProfilerPhase.scope("3d:world_post");
683
             TracyGpuProfiler.Scope gpuScope = TracyGpuProfiler.beginZone("3d:world_post")) {
684
            float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
685
            float fov = mainCamera.getFov();
686
            Matrix4f capturedPosition = CombatantWorldMatrices.positionMatrix();
687
            Matrix4f capturedProjection = CombatantWorldMatrices.renderProjectionMatrix();
688
            boolean useCapturedMatrices = capturedPosition != null && capturedProjection != null;
689
            Matrix4f position = useCapturedMatrices
690
                    ? capturedPosition
691
                    : new Matrix4f().rotation(mainCamera.rotation().conjugate(new org.joml.Quaternionf()));
692
693
            RenderState.rendering3D = true;
694
            Vec3 capturedCameraPos = CombatantWorldMatrices.cameraPosition();
695
            RenderState.cameraPos = capturedCameraPos != null ? capturedCameraPos : mainCamera.position();
696
            RenderState.cameraRotation.set(mainCamera.rotation());
697
            RenderState.cameraYaw = mainCamera.yRot();
698
            RenderState.cameraPitch = mainCamera.xRot();
699
700
            if (combatant$postRenderer == null) {
701
                combatant$postRenderer = new Renderer3D(
702
                        CombatantRenderPipelines.WORLD_COLORED_LINES,
703
                        CombatantRenderPipelines.WORLD_COLORED
704
                );
705
            }
706
707
            if (combatant$postDepthRenderer == null) {
708
                combatant$postDepthRenderer = new Renderer3D(
709
                        CombatantRenderPipelines.WORLD_COLORED_LINES_DEPTH,
710
                        CombatantRenderPipelines.WORLD_COLORED_DEPTH
711
                );
712
            }
713
714
            var mv = com.mojang.blaze3d.systems.RenderSystem.getModelViewStack();
715
            mv.pushMatrix();
716
            if (IrisCombatantFrameHooks.isRenderingAfterIrisFinalization()) {
717
                mv.identity();
718
            }
719
            mv.mul(position);
720
            combatant$postMatrices.pushPose();
721
            Matrix4f projection = useCapturedMatrices
722
                    ? capturedProjection
723
                    : combatant$buildWorldProjection(fov, combatant$postMatrices, tickDelta);
724
            MeshRenderer.setProjection(projection);
725
            CombatantRenderSystem.beginFrame(
726
                    tickDelta,
727
                    tickCounter.getGameTimeDeltaTicks(),
728
                    tickCounter.getRealtimeDeltaTicks(),
729
                    projection,
730
                    new Matrix4f(mv)
731
            );
732
            try (RenderPhaseScope combatant$postWorldPhase = CombatantRenderSystem.phase(RenderPhase.WORLD_POST_PRE_HAND)) {
733
                RenderState.worldProjection.set(projection);
734
                RenderState.frustum = new Frustum(position, projection);
735
                RenderState.frustum.prepare(RenderState.cameraPos.x, RenderState.cameraPos.y, RenderState.cameraPos.z);
736
737
                if (!useCapturedMatrices) {
738
                    Matrix4f inverseBob = new Matrix4f(combatant$postMatrices.last().pose()).invert();
739
                    mv.mul(inverseBob);
740
                }
741
742
                combatant$postRenderer.begin();
743
                combatant$postDepthRenderer.begin();
744
745
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:post_modules");
746
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("modules")) {
747
                    ModuleManager.renderWorldEngine(WorldPhase.AFTER_POST_PROCESS, combatant$postRenderer, combatant$postDepthRenderer, tickDelta);
748
                    AddonRenderPipelineManager.render3D(CombatantRenderStage.WORLD_POST_PROCESS,
749
                            WorldPhase.AFTER_POST_PROCESS, combatant$postRenderer, combatant$postDepthRenderer, combatant$postMatrices, tickDelta);
750
                }
751
752
                try (ProfilerPhase.Scope phase = ProfilerPhase.scope("3d:post_flush");
753
                     TracyGpuProfiler.Scope gpuFlush = TracyGpuProfiler.beginZone("3d:post_flush");
754
                     RenderProfiler3D.Section ignored = RenderProfiler3D.section("flush")) {
755
                    combatant$postRenderer.render(combatant$postMatrices);
756
                    combatant$postDepthRenderer.render(combatant$postMatrices);
757
                }
758
            }
759
            combatant$postMatrices.popPose();
760
            mv.popMatrix();
761
            RenderState.rendering3D = false;
762
        }
763
    }
764
765
    @Unique
766
    private Matrix4f combatant$buildWorldProjection(float fov, PoseStack viewEffectMatrices, float tickDelta) {
767
        CameraRenderState cameraRenderState = new CameraRenderState();
768
        mainCamera.extractRenderState(cameraRenderState, fov);
769
        Matrix4f projection = new Matrix4f(cameraRenderState.projectionMatrix);
770
        combatant$applyViewEffectMatrices(viewEffectMatrices, tickDelta);
771
        projection.mul(viewEffectMatrices.last().pose());
772
        combatant$applyNauseaProjection(projection, tickDelta);
773
        return projection;
774
    }
775
776
    @Unique
777
    private void combatant$applyViewEffectMatrices(PoseStack matrices, float cameraTickProgress) {
778
        NoRender noRender = Modules.get(NoRender.class);
779
        CameraRenderState cameraRenderState = new CameraRenderState();
780
        mainCamera.extractRenderState(cameraRenderState, mainCamera.getFov());
781
        if (noRender == null || !noRender.off("camera_shake")) {
782
            bobHurt(cameraRenderState, matrices);
783
        }
784
785
        boolean freecamEnabled = Modules.get(Freecam.class) != null && Modules.get(Freecam.class).isEnabled();
786
        if (minecraft.options.bobView().get()
787
                && !freecamEnabled
788
                && (noRender == null || !noRender.off("view_bob"))) {
789
            bobView(cameraRenderState, matrices);
790
        }
791
    }
792
793
    @Unique
794
    private void combatant$applyNauseaProjection(Matrix4f projection, float tickDelta) {
795
        LocalPlayer player = minecraft.player;
796
        if (player == null) return;
797
798
        float distortionScale = minecraft.options.screenEffectScale().get().floatValue();
799
        if (distortionScale <= 0.0f) return;
800
801
        float nauseaIntensity = 0.0f;
802
        if (player instanceof LocalPlayerAccessor accessor) {
803
            nauseaIntensity = Mth.lerp(
804
                    tickDelta,
805
                    accessor.combatant$getLastNauseaIntensity(),
806
                    accessor.combatant$getNauseaIntensity()
807
            );
808
        }
809
810
        float nauseaEffect = player.getEffectBlendFactor(MobEffects.NAUSEA, tickDelta);
811
        float strength = Math.max(nauseaIntensity, nauseaEffect) * (distortionScale * distortionScale);
812
        if (strength <= 0.0f) return;
813
814
        float scale = 5.0f / (strength * strength + 5.0f) - strength * 0.04f;
815
        scale *= scale;
816
        Vector3f axis = new Vector3f(0.0f, Mth.SQRT_OF_TWO / 2.0f, Mth.SQRT_OF_TWO / 2.0f);
817
        float angle = (this.spinningEffectTime + tickDelta * this.spinningEffectSpeed) * Mth.DEG_TO_RAD;
818
        projection.rotate(angle, axis);
819
        projection.scale(1.0f / scale, 1.0f, 1.0f);
820
        projection.rotate(-angle, axis);
821
    }
822
823
    @Inject(method = "renderItemInHand(Lnet/minecraft/client/renderer/state/level/CameraRenderState;FLorg/joml/Matrix4fc;)V", at = @At("HEAD"), cancellable = true)
824
    private void freecam$hand(CameraRenderState cameraRenderState, float tickDelta, Matrix4fc positionMatrix, CallbackInfo ci) {
825
        if (ClickGuiRenderer.suppressesBackgroundRendering() || VisualPreviewRuntime.isActive()) {
826
            ci.cancel();
827
            return;
828
        }
829
        Freecam fc = Modules.get(Freecam.class);
830
        if (fc != null && fc.isEnabled() && !fc.renderHand()) {
831
            ci.cancel();
832
        }
833
    }
834
835
    @WrapOperation(
836
            method = "renderItemInHand(Lnet/minecraft/client/renderer/state/level/CameraRenderState;FLorg/joml/Matrix4fc;)V",
837
            at = @At(
838
                    value = "INVOKE",
839
                    target = "Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher;renderAllFeatures(Lnet/minecraft/client/renderer/SubmitNodeStorage;)V"
840
            )
841
    )
842
    private void combatant$renderChamsHandPreparedFrame(FeatureRenderDispatcher dispatcher,
843
                                                        SubmitNodeStorage storage,
844
                                                        Operation<Void> original,
845
                                                        CameraRenderState cameraRenderState,
846
                                                        float tickDelta,
847
                                                        Matrix4fc positionMatrix) {
848
        Chams module = Modules.get(Chams.class);
849
        SubmitNodeStorage snapshot = module != null ? module.snapshotPreparedHandScene(storage) : null;
850
851
        // Render Minecraft's live hand storage first. renderAllFeatures() consumes it in 26.2.
852
        original.call(dispatcher, storage);
853
854
        // Chams renders only the isolated snapshot afterwards; it must never consume the live storage.
855
        if (module != null && snapshot != null) {
856
            module.renderPreparedHandScene(snapshot);
857
        }
858
    }
859
860
    @Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V", at = @At("TAIL"))
861
    private void combatant$flushQueuedButtons(DeltaTracker tickCounter, boolean tick, CallbackInfo ci) {
862
        Minecraft mc = Minecraft.getInstance();
863
        if (mc != null && ClientScreen.current() != null) {
864
            if (BetterButtons.hasPending()) {
865
                BetterButtons.flush();
866
            }
867
            BetterTooltips.renderTooltipWithContext(BetterButtons.getLastContext());
868
        }
869
870
        // This is the actual final Combatant 2D drain for the frame. BetterButtons and
871
        // BetterTooltips intentionally render from this TAIL hook, so draining SCREEN_ABSOLUTE_TOP
872
        // any earlier (for example immediately after GuiRenderer.render()) still allowed those
873
        // screen-owned surfaces to cover the debug HUD.
874
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.SCREEN_ABSOLUTE_TOP);
875
    }
876
877
    @Inject(
878
            method = "render(Lnet/minecraft/client/DeltaTracker;Z)V",
879
            at = @At(
880
                    value = "INVOKE",
881
                    target = "Lnet/minecraft/client/gui/render/GuiRenderer;render()V",
882
                    shift = At.Shift.BEFORE
883
            )
884
    )
885
    private void combatant$captureWorldForHudGlass(DeltaTracker tickCounter, boolean tick, CallbackInfo ci) {
886
        if (!combatant.client.runtime.RuntimeGate.canRunRender()) {
887
            MenuBackgroundRenderer.clearDeferred();
888
            return;
889
        }
890
        MenuBackgroundRenderer.drainDeferred(minecraft);
891
        Renderer2D.prepareDeferredUiItems();
892
        UiBlurResources.captureWorldSource();
893
        if (AddonRenderPipelineManager.hasActiveCallbacks(CombatantRenderStage.SCREEN_BEFORE_VANILLA_GUI)) {
894
            float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
895
            Renderer2D.COLOR.begin();
896
            AddonRenderPipelineManager.render2D(CombatantRenderStage.SCREEN_BEFORE_VANILLA_GUI,
897
                    null, Renderer2D.COLOR, TextRenderer.get(), null, tickDelta);
898
            Renderer2D.COLOR.render();
899
        }
900
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.BEFORE_VANILLA_GUI);
901
        combatant$drainHudLayersBelowScreenGui();
902
    }
903
904
    /**
905
     * Gui.extractRenderState() extracts vanilla HUD first and the current Screen after it.
906
     * Normal gameplay keeps Combatant HUD spliced into that HUD order through HudDeferredGuiElement
907
     * markers. When a real Screen is open, however, the screen must remain the top GUI owner:
908
     * HUD/world overlaysare drained before GuiRenderer.render(),
909
     * preserving their internal order while keeping container/inventory GUI above them.
910
     * Explicit SCREEN_TOP/AFTER_VANILLA_GUI overlays (Dynamic Island, ClickGui top layer, etc.) are
911
     * intentionally not drained here.
912
     */
913
    @Unique
914
    private static void combatant$drainHudLayersBelowScreenGui() {
915
        if (ClientScreen.current() == null) {
916
            return;
917
        }
918
919
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_FIRST);
920
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_BEFORE_MISC_OVERLAYS);
921
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_AFTER_MISC_OVERLAYS);
922
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_AFTER_BOSS_BAR);
923
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_BEFORE_DEMO_TIMER);
924
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_BEFORE_CHAT);
925
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_AFTER_SUBTITLES);
926
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.HUD_LAST);
927
    }
928
929
    @Inject(
930
            method = "render(Lnet/minecraft/client/DeltaTracker;Z)V",
931
            at = @At(
932
                    value = "INVOKE",
933
                    target = "Lnet/minecraft/client/gui/render/GuiRenderer;render()V",
934
                    shift = At.Shift.AFTER
935
            )
936
    )
937
    private void combatant$debug2dImmediateAfterGui(DeltaTracker tickCounter, boolean tick, CallbackInfo ci) {
938
        Renderer2D.drainDeferred2D(Renderer2D.Deferred2DLayer.AFTER_VANILLA_GUI);
939
        if (AddonRenderPipelineManager.hasActiveCallbacks(CombatantRenderStage.SCREEN_AFTER_VANILLA_GUI)) {
940
            float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
941
            Renderer2D.COLOR.begin();
942
            AddonRenderPipelineManager.render2D(CombatantRenderStage.SCREEN_AFTER_VANILLA_GUI,
943
                    null, Renderer2D.COLOR, TextRenderer.get(), null, tickDelta);
944
            Renderer2D.COLOR.render();
945
        }
946
        UiClipDebugScene.renderAfterGui();
947
    }
948
949
@Inject(method = "bobHurt", at = @At("HEAD"), cancellable = true)
950
    private void combatant$disableHurtCamera(CameraRenderState cameraRenderState, PoseStack matrices, CallbackInfo ci) {
951
        NoRender noRender = Modules.get(NoRender.class);
952
        if (noRender != null && noRender.off("camera_shake")) {
953
            ci.cancel();
954
        }
955
    }
956
957
    @Inject(method = "bobView", at = @At("HEAD"), cancellable = true)
958
    private void combatant$disableViewBobbing(CameraRenderState cameraRenderState, PoseStack matrices, CallbackInfo ci) {
959
        Freecam freecam = Modules.get(Freecam.class);
960
        if (freecam != null && freecam.isEnabled()) {
961
            ci.cancel();
962
            return;
963
        }
964
965
        NoRender noRender = Modules.get(NoRender.class);
966
        if (noRender != null && noRender.off("view_bob")) {
967
            ci.cancel();
968
        }
969
    }
970
}
971
GlCommandEncoderMixinsrc/main/java/combatant/client/mixins/GlCommandEncoderMixin.javaJava · 56 lines · 2.1 KB
@Mixin(targets = "com.mojang.blaze3d.opengl.GlCommandEncoder")
GlCommandEncoderMixin.javaJava · 56 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import combatant.client.util.logging.DebugLog;
13
import combatant.client.render.engine.rhi.backend.gl.GlNativeStateTracker;
14
import net.minecraft.resources.Identifier;
15
import org.slf4j.Logger;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
19
/**
20
 * GlCommandEncoder is package-private in Mojang's OpenGL backend, so this mixin
21
 * intentionally targets it by binary name instead of importing the class.
22
 */
23
@Mixin(targets = "com.mojang.blaze3d.opengl.GlCommandEncoder")
24
public abstract class GlCommandEncoderMixin {
25
    @WrapOperation(
26
            method = "trySetup",
27
            at = @At(
28
                    value = "INVOKE",
29
                    target = "Lcom/mojang/blaze3d/opengl/GlStateManager;_glUseProgram(I)V"
30
            )
31
    )
32
    private void combatant$trackBlaze3dProgram(int program, Operation<Void> original) {
33
        original.call(program);
34
        GlNativeStateTracker.recordBlaze3dProgram(program);
35
    }
36
37
    @WrapOperation(
38
            method = "trySetup",
39
            at = @At(
40
                    value = "INVOKE",
41
                    target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"
42
            )
43
    )
44
    private void combatant$wrapPipelineWarning(Logger logger,
45
                                                 String format,
46
                                                 Object pipelineId,
47
                                                 Operation<Void> original) {
48
        if (pipelineId instanceof Identifier id && "combatant".equals(id.getNamespace())) {
49
            DebugLog.warn("[RenderPipeline] Render pipeline %s wants a depth texture but none was provided - this is probably a bug", id);
50
            return;
51
        }
52
53
        original.call(logger, format, pipelineId);
54
    }
55
}
56
GlDeviceBackendMixinsrc/main/java/combatant/client/mixins/GlDeviceBackendMixin.javaJava · 239 lines · 9.1 KB
@Mixin(targets = "com.mojang.blaze3d.opengl.GlDevice")
GlDeviceBackendMixin.javaJava · 239 lines · 9.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.opengl.DirectStateAccess;
11
import com.mojang.blaze3d.opengl.FrameBufferCache;
12
import com.mojang.blaze3d.opengl.GlRenderPipeline;
13
import com.mojang.blaze3d.opengl.VertexArrayCache;
14
import com.mojang.blaze3d.pipeline.RenderPipeline;
15
import com.mojang.blaze3d.shaders.ShaderSource;
16
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
17
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
18
import combatant.client.util.logging.DebugLog;
19
import net.minecraft.resources.Identifier;
20
import org.slf4j.Logger;
21
import org.lwjgl.opengl.GLCapabilities;
22
import org.lwjgl.opengl.GL11C;
23
import combatant.client.render.engine.profiler.ProfilerPhase;
24
import combatant.client.render.engine.rhi.backend.gl.GlNativeStateTracker;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.Shadow;
27
import org.spongepowered.asm.mixin.Unique;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
31
import org.spongepowered.asm.mixin.gen.Invoker;
32
import combatant.client.mixininterface.IGlBackendInfo;
33
34
@Mixin(targets = "com.mojang.blaze3d.opengl.GlDevice")
35
public abstract class GlDeviceBackendMixin implements IGlBackendInfo {
36
    @Shadow
37
    protected static boolean USE_GL_KHR_debug;
38
    @Shadow
39
    protected static boolean USE_GL_ARB_direct_state_access;
40
41
    @Override
42
    @Invoker("directStateAccess")
43
    public abstract DirectStateAccess combatant$directStateAccess();
44
45
    @Override
46
    @Invoker("frameBufferCache")
47
    public abstract FrameBufferCache combatant$frameBufferCache();
48
49
    @Override
50
    @Invoker("vertexArrayCache")
51
    public abstract VertexArrayCache combatant$vertexArrayCache();
52
53
    @Override
54
    public boolean combatant$nativeDirectStateAccess() {
55
        return USE_GL_ARB_direct_state_access;
56
    }
57
58
    @Override
59
    public boolean combatant$khrDebug() {
60
        return USE_GL_KHR_debug;
61
    }
62
63
    @WrapOperation(
64
            method = "<init>",
65
            at = @At(
66
                    value = "INVOKE",
67
                    target = "Lorg/lwjgl/opengl/GL;createCapabilities()Lorg/lwjgl/opengl/GLCapabilities;"
68
            )
69
    )
70
    private GLCapabilities combatant$captureMojangGlCapabilities(Operation<GLCapabilities> original) {
71
        GLCapabilities caps = original.call();
72
        GlNativeStateTracker.resetBlaze3dProgram();
73
        combatant$computeShaders = caps.OpenGL43 || caps.GL_ARB_compute_shader;
74
        combatant$tessellationShaders = caps.OpenGL40 || caps.GL_ARB_tessellation_shader;
75
        combatant$geometryShaders = caps.OpenGL32 || caps.GL_ARB_geometry_shader4;
76
        combatant$shaderStorageBuffers = caps.OpenGL43 || caps.GL_ARB_shader_storage_buffer_object;
77
        combatant$imageLoadStore = caps.OpenGL42 || caps.GL_ARB_shader_image_load_store;
78
        combatant$multiBind = caps.OpenGL44 || caps.GL_ARB_multi_bind;
79
        combatant$copyImage = caps.OpenGL43 || caps.GL_ARB_copy_image;
80
        combatant$attachmentInvalidation = caps.OpenGL43 || caps.GL_ARB_invalidate_subdata;
81
        combatant$vendor = combatant$glString(GL11C.GL_VENDOR);
82
        combatant$renderer = combatant$glString(GL11C.GL_RENDERER);
83
        return caps;
84
    }
85
86
    @Override
87
    public boolean combatant$computeShaders() { return combatant$computeShaders; }
88
89
    @Override
90
    public boolean combatant$tessellationShaders() { return combatant$tessellationShaders; }
91
92
    @Override
93
    public boolean combatant$geometryShaders() { return combatant$geometryShaders; }
94
95
    @Override
96
    public boolean combatant$shaderStorageBuffers() { return combatant$shaderStorageBuffers; }
97
98
    @Override
99
    public boolean combatant$imageLoadStore() { return combatant$imageLoadStore; }
100
101
    @Override
102
    public boolean combatant$multiBind() { return combatant$multiBind; }
103
104
    @Override
105
    public boolean combatant$copyImage() { return combatant$copyImage; }
106
107
    @Override
108
    public boolean combatant$attachmentInvalidation() { return combatant$attachmentInvalidation; }
109
    @Override
110
    public String combatant$vendor() { return combatant$vendor; }
111
112
    @Override
113
    public String combatant$renderer() { return combatant$renderer; }
114
115
    @Unique
116
    private static String combatant$glString(int name) {
117
        try {
118
            String value = GL11C.glGetString(name);
119
            return value == null ? "" : value;
120
        } catch (Throwable ignored) {
121
            return "";
122
        }
123
    }
124
125
    @Unique private boolean combatant$computeShaders;
126
    @Unique private boolean combatant$tessellationShaders;
127
    @Unique private boolean combatant$geometryShaders;
128
    @Unique private boolean combatant$shaderStorageBuffers;
129
    @Unique private boolean combatant$imageLoadStore;
130
    @Unique private boolean combatant$multiBind;
131
    @Unique private boolean combatant$copyImage;
132
    @Unique private boolean combatant$attachmentInvalidation;
133
    @Unique private String combatant$vendor = "";
134
    @Unique private String combatant$renderer = "";
135
136
    @Unique
137
    private ProfilerPhase.Scope combatant$pipelineCompileScope;
138
139
140
    @WrapOperation(
141
            method = {"compileShader", "compileProgram"},
142
            at = @At(
143
                    value = "INVOKE",
144
                    target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"
145
            )
146
    )
147
    private void combatant$wrapCombatantCompileError(Logger logger,
148
                                                       String format,
149
                                                       Object first,
150
                                                       Object second,
151
                                                       Operation<Void> original) {
152
        if (combatant$containsCombatantId(first) || combatant$containsCombatantId(second)) {
153
            DebugLog.error("[RenderPipeline] " + combatant$formatSlf4j(format, first, second));
154
            return;
155
        }
156
157
        original.call(logger, format, first, second);
158
    }
159
160
    @WrapOperation(
161
            method = "compileShader",
162
            at = @At(
163
                    value = "INVOKE",
164
                    target = "Lorg/slf4j/Logger;error(Ljava/lang/String;[Ljava/lang/Object;)V"
165
            )
166
    )
167
    private void combatant$wrapCombatantShaderCompileError(Logger logger,
168
                                                             String format,
169
                                                             Object[] args,
170
                                                             Operation<Void> original) {
171
        if (combatant$containsCombatantId(args)) {
172
            DebugLog.error("[RenderPipeline] " + combatant$formatSlf4j(format, args));
173
            return;
174
        }
175
176
        original.call(logger, format, args);
177
    }
178
179
    @Unique
180
    private static boolean combatant$containsCombatantId(Object value) {
181
        if (value instanceof Identifier id) {
182
            return "combatant".equals(id.getNamespace());
183
        }
184
        if (value instanceof Object[] values) {
185
            for (Object element : values) {
186
                if (combatant$containsCombatantId(element)) {
187
                    return true;
188
                }
189
            }
190
        }
191
        return false;
192
    }
193
194
    @Unique
195
    private static String combatant$formatSlf4j(String format, Object... args) {
196
        String template = String.valueOf(format);
197
        if (args == null || args.length == 0) {
198
            return template;
199
        }
200
201
        StringBuilder out = new StringBuilder(template.length() + args.length * 16);
202
        int cursor = 0;
203
        int argIndex = 0;
204
        while (argIndex < args.length) {
205
            int placeholder = template.indexOf("{}", cursor);
206
            if (placeholder < 0) {
207
                break;
208
            }
209
            out.append(template, cursor, placeholder);
210
            out.append(String.valueOf(args[argIndex++]));
211
            cursor = placeholder + 2;
212
        }
213
        out.append(template, cursor, template.length());
214
        while (argIndex < args.length) {
215
            out.append(' ').append(String.valueOf(args[argIndex++]));
216
        }
217
        return out.toString();
218
    }
219
220
    @Inject(method = "compilePipeline", at = @At("HEAD"))
221
    private void combatant$profilePipelineCompileHead(RenderPipeline pipeline, ShaderSource shaderSource, CallbackInfoReturnable<GlRenderPipeline> cir) {
222
        ProfilerPhase.Scope staleScope = combatant$pipelineCompileScope;
223
        combatant$pipelineCompileScope = null;
224
        if (staleScope != null) staleScope.close();
225
226
        if (ProfilerPhase.isActive()) {
227
            combatant$pipelineCompileScope = ProfilerPhase.scope("gl:compile_pipeline");
228
        }
229
    }
230
231
    @Inject(method = "compilePipeline", at = @At("RETURN"))
232
    private void combatant$profilePipelineCompileReturn(RenderPipeline pipeline, ShaderSource shaderSource, CallbackInfoReturnable<GlRenderPipeline> cir) {
233
        ProfilerPhase.Scope scope = combatant$pipelineCompileScope;
234
        combatant$pipelineCompileScope = null;
235
        if (scope != null) scope.close();
236
    }
237
238
}
239
GlProgramMixinsrc/main/java/combatant/client/mixins/GlProgramMixin.javaJava · 117 lines · 4.4 KB
@Mixin(GlProgram.class)
ModifiesGlProgram
GlProgramMixin.javaJava · 117 lines · 4.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.opengl.GlProgram;
13
import com.mojang.blaze3d.opengl.GlShaderModule;
14
import com.mojang.blaze3d.vertex.VertexFormat;
15
import net.minecraft.resources.Identifier;
16
import org.slf4j.Logger;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.Unique;
19
import org.spongepowered.asm.mixin.injection.At;
20
import combatant.client.util.logging.DebugLog;
21
22
@Mixin(GlProgram.class)
23
public abstract class GlProgramMixin {
24
    @Unique
25
    private static final String combatant$namespace = "combatant";
26
27
    @WrapOperation(
28
            method = "link",
29
            at = @At(
30
                    value = "INVOKE",
31
                    target = "Lorg/slf4j/Logger;info(Ljava/lang/String;[Ljava/lang/Object;)V"
32
            )
33
    )
34
    private static void combatant$wrapProgramLinkInfo(Logger logger,
35
                                                       String format,
36
                                                       Object[] args,
37
                                                       Operation<Void> original,
38
                                                       GlShaderModule vertexShader,
39
                                                       GlShaderModule fragmentShader,
40
                                                       VertexFormat[] vertexFormats,
41
                                                       String debugLabel) {
42
        if (combatant$isCombatantShader(vertexShader)
43
                || combatant$isCombatantShader(fragmentShader)
44
                || combatant$isCombatantLabel(debugLabel)) {
45
            DebugLog.renderThread("[RenderPipeline] %s", combatant$formatSlf4j(format, args));
46
            return;
47
        }
48
49
        original.call(logger, format, args);
50
    }
51
52
    @WrapOperation(
53
            method = "setupBindGroupLayouts",
54
            at = @At(
55
                    value = "INVOKE",
56
                    target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"
57
            )
58
    )
59
    private void combatant$wrapPipelineWarning(Logger logger,
60
                                                 String format,
61
                                                 Object first,
62
                                                 Object second,
63
                                                 Operation<Void> original) {
64
        String debugLabel = ((GlProgram) (Object) this).getDebugLabel();
65
        if (combatant$isCombatantLabel(debugLabel)) {
66
            DebugLog.warn("[RenderPipeline] %s", combatant$formatSlf4j(format, first, second));
67
            return;
68
        }
69
70
        original.call(logger, format, first, second);
71
    }
72
73
    @Unique
74
    private static boolean combatant$isCombatantShader(GlShaderModule shader) {
75
        return shader != null && combatant$isCombatantId(shader.getId());
76
    }
77
78
    @Unique
79
    private static boolean combatant$isCombatantId(Identifier id) {
80
        return id != null && combatant$namespace.equals(id.getNamespace());
81
    }
82
83
    @Unique
84
    private static boolean combatant$isCombatantLabel(String label) {
85
        if (label == null || label.isEmpty()) {
86
            return false;
87
        }
88
        return label.startsWith(combatant$namespace + ":") || label.startsWith("Combatant");
89
    }
90
91
    @Unique
92
    private static String combatant$formatSlf4j(String format, Object... args) {
93
        String template = String.valueOf(format);
94
        if (args == null || args.length == 0) {
95
            return template;
96
        }
97
98
        StringBuilder out = new StringBuilder(template.length() + args.length * 16);
99
        int cursor = 0;
100
        int argIndex = 0;
101
        while (argIndex < args.length) {
102
            int placeholder = template.indexOf("{}", cursor);
103
            if (placeholder < 0) {
104
                break;
105
            }
106
            out.append(template, cursor, placeholder);
107
            out.append(String.valueOf(args[argIndex++]));
108
            cursor = placeholder + 2;
109
        }
110
        out.append(template, cursor, template.length());
111
        while (argIndex < args.length) {
112
            out.append(' ').append(String.valueOf(args[argIndex++]));
113
        }
114
        return out.toString();
115
    }
116
}
117
GlStateManagerMixinsrc/main/java/combatant/client/mixins/GlStateManagerMixin.javaJava · 34 lines · 1.3 KB
@Mixin(GlStateManager.class)
GlStateManagerMixin.javaJava · 34 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.opengl.GlStateManager;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Inject;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15
import combatant.client.render.engine.profiler.GlSyncTracker;
16
17
@Mixin(GlStateManager.class)
18
public class GlStateManagerMixin {
19
    @Inject(method = "_glFenceSync", at = @At("RETURN"))
20
    private static void combatant$onFenceSync(int condition, int flags, CallbackInfoReturnable<Long> cir) {
21
        GlSyncTracker.onFence(cir.getReturnValue());
22
    }
23
24
    @Inject(method = "_glClientWaitSync", at = @At("HEAD"))
25
    private static void combatant$onClientWaitSync(long sync, int flags, long timeout, CallbackInfoReturnable<Integer> cir) {
26
        GlSyncTracker.onWaitStart(sync);
27
    }
28
29
    @Inject(method = "_glClientWaitSync", at = @At("RETURN"))
30
    private static void combatant$onClientWaitSyncReturn(long sync, int flags, long timeout, CallbackInfoReturnable<Integer> cir) {
31
        GlSyncTracker.onWaitEnd();
32
    }
33
}
34
GlTextureMixinsrc/main/java/combatant/client/mixins/GlTextureMixin.javaJava · 59 lines · 1.4 KB
@Mixin(GlTexture.class)
ModifiesGlTexture
GlTextureMixin.javaJava · 59 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.opengl.GlTexture;
11
import org.spongepowered.asm.mixin.Final;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Shadow;
14
import org.spongepowered.asm.mixin.Unique;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.mixininterface.IMsaaTexture;
19
import combatant.client.render.engine.core.CombatantRenderSystem;
20
21
@Mixin(GlTexture.class)
22
public abstract class GlTextureMixin implements IMsaaTexture {
23
    @Final
24
    @Shadow
25
    protected int id;
26
27
    @Unique
28
    private int combatant$samples = 1;
29
30
    @Override
31
    public void combatant$setSamples(int samples) {
32
        combatant$samples = samples;
33
    }
34
35
    @Override
36
    public int combatant$getSamples() {
37
        return combatant$samples;
38
    }
39
40
    @Override
41
    public boolean combatant$isMsaa() {
42
        return combatant$samples > 1;
43
    }
44
45
    @Override
46
    public int combatant$getGlId() {
47
        return id;
48
    }
49
50
    @Inject(method = "destroyImmediately", at = @At("HEAD"))
51
    private void combatant$onFree(CallbackInfo ci) {
52
        CombatantRenderSystem.rhi().msaa().unregisterTexture(id);
53
    }
54
}
55
56
57
58
59
GpuDeviceMixinsrc/main/java/combatant/client/mixins/GpuDeviceMixin.javaJava · 120 lines · 6.5 KB
@Mixin(GpuDevice.class)
ModifiesGpuDevice
GpuDeviceMixin.javaJava · 120 lines · 6.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.GpuFormat;
11
import com.mojang.blaze3d.systems.GpuDevice;
12
import com.mojang.blaze3d.systems.GpuDeviceBackend;
13
import com.mojang.blaze3d.buffers.GpuBuffer;
14
import com.mojang.blaze3d.pipeline.CompiledRenderPipeline;
15
import com.mojang.blaze3d.pipeline.RenderPipeline;
16
import com.mojang.blaze3d.shaders.ShaderSource;
17
import com.mojang.blaze3d.textures.GpuTexture;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.injection.At;
20
import org.spongepowered.asm.mixin.injection.Redirect;
21
22
import java.nio.ByteBuffer;
23
import java.util.function.Supplier;
24
import combatant.client.mixininterface.IGpuDevice;
25
import combatant.client.mixininterface.IMsaaDevice;
26
import combatant.client.render.engine.core.CombatantRenderSystem;
27
import combatant.client.render.engine.rhi.scissor.GlobalScissorState;
28
import combatant.client.render.engine.profiler.ProfilerPhase;
29
30
@Mixin(GpuDevice.class)
31
public abstract class GpuDeviceMixin implements IGpuDevice, IMsaaDevice {
32
    @Override
33
    public void combatant$pushScissor(int x, int y, int width, int height) {
34
        GlobalScissorState.push(x, y, width, height);
35
    }
36
37
    @Override
38
    public void combatant$popScissor() {
39
        GlobalScissorState.pop();
40
    }
41
42
    @Override
43
    public GpuTexture combatant$createMsaaTexture(String label, int usage, GpuFormat format, int width, int height, int samples) {
44
        return CombatantRenderSystem.rhi().msaa().createTexture(label, usage, format, width, height, samples);
45
    }
46
47
    @Redirect(
48
            method = "createTexture(Ljava/util/function/Supplier;ILcom/mojang/blaze3d/GpuFormat;IIII)Lcom/mojang/blaze3d/textures/GpuTexture;",
49
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDeviceBackend;createTexture(Ljava/util/function/Supplier;ILcom/mojang/blaze3d/GpuFormat;IIII)Lcom/mojang/blaze3d/textures/GpuTexture;")
50
    )
51
    private GpuTexture combatant$profileCreateTexture(GpuDeviceBackend backend,
52
                                                       Supplier<String> label,
53
                                                       int usage,
54
                                                       GpuFormat format,
55
                                                       int width,
56
                                                       int height,
57
                                                       int depthOrLayers,
58
                                                       int mipLevels) {
59
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_resource:create_texture")) {
60
            return backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
61
        }
62
    }
63
64
    @Redirect(
65
            method = "createTexture(Ljava/lang/String;ILcom/mojang/blaze3d/GpuFormat;IIII)Lcom/mojang/blaze3d/textures/GpuTexture;",
66
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDeviceBackend;createTexture(Ljava/lang/String;ILcom/mojang/blaze3d/GpuFormat;IIII)Lcom/mojang/blaze3d/textures/GpuTexture;")
67
    )
68
    private GpuTexture combatant$profileCreateTextureNamed(GpuDeviceBackend backend,
69
                                                            String label,
70
                                                            int usage,
71
                                                            GpuFormat format,
72
                                                            int width,
73
                                                            int height,
74
                                                            int depthOrLayers,
75
                                                            int mipLevels) {
76
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_resource:create_texture")) {
77
            return backend.createTexture(label, usage, format, width, height, depthOrLayers, mipLevels);
78
        }
79
    }
80
81
    @Redirect(
82
            method = "createBuffer(Ljava/util/function/Supplier;IJ)Lcom/mojang/blaze3d/buffers/GpuBuffer;",
83
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDeviceBackend;createBuffer(Ljava/util/function/Supplier;IJ)Lcom/mojang/blaze3d/buffers/GpuBuffer;")
84
    )
85
    private GpuBuffer combatant$profileCreateBuffer(GpuDeviceBackend backend,
86
                                                     Supplier<String> label,
87
                                                     int usage,
88
                                                     long size) {
89
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_resource:create_buffer")) {
90
            return backend.createBuffer(label, usage, size);
91
        }
92
    }
93
94
    @Redirect(
95
            method = "createBuffer(Ljava/util/function/Supplier;ILjava/nio/ByteBuffer;)Lcom/mojang/blaze3d/buffers/GpuBuffer;",
96
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDeviceBackend;createBuffer(Ljava/util/function/Supplier;ILjava/nio/ByteBuffer;)Lcom/mojang/blaze3d/buffers/GpuBuffer;")
97
    )
98
    private GpuBuffer combatant$profileCreateBufferWithData(GpuDeviceBackend backend,
99
                                                             Supplier<String> label,
100
                                                             int usage,
101
                                                             ByteBuffer data) {
102
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_resource:create_buffer_with_data")) {
103
            return backend.createBuffer(label, usage, data);
104
        }
105
    }
106
107
    @Redirect(
108
            method = "precompilePipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lcom/mojang/blaze3d/shaders/ShaderSource;)Lcom/mojang/blaze3d/pipeline/CompiledRenderPipeline;",
109
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuDeviceBackend;precompilePipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lcom/mojang/blaze3d/shaders/ShaderSource;)Lcom/mojang/blaze3d/pipeline/CompiledRenderPipeline;")
110
    )
111
    private CompiledRenderPipeline combatant$profilePipelineCompile(GpuDeviceBackend backend,
112
                                                                     RenderPipeline pipeline,
113
                                                                     ShaderSource shaderSource) {
114
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("gpu_resource:compile_pipeline")) {
115
            return backend.precompilePipeline(pipeline, shaderSource);
116
        }
117
    }
118
119
}
120
GpuSurfaceMixinsrc/main/java/combatant/client/mixins/GpuSurfaceMixin.javaJava · 106 lines · 4.5 KB
@Mixin(GpuSurface.class)
ModifiesGpuSurface
GpuSurfaceMixin.javaJava · 106 lines · 4.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.systems.CommandEncoder;
11
import com.mojang.blaze3d.systems.CommandEncoderBackend;
12
import com.mojang.blaze3d.systems.GpuSurface;
13
import com.mojang.blaze3d.systems.GpuSurfaceBackend;
14
import com.mojang.blaze3d.systems.SurfaceException;
15
import com.mojang.blaze3d.textures.GpuTextureView;
16
import combatant.client.render.engine.animation.AnimationUtility;
17
import combatant.client.render.engine.core.CombatantRenderSystem;
18
import combatant.client.render.engine.profiler.ProfilerPhase;
19
import combatant.client.render.engine.profiler.TracyGpuProfiler;
20
import combatant.client.render.engine.renderer.Renderer2D;
21
import combatant.client.render.engine.renderer.ui.UiBlurResources;
22
import combatant.client.util.FastFps;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.injection.At;
25
import org.spongepowered.asm.mixin.injection.Inject;
26
import org.spongepowered.asm.mixin.injection.Redirect;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
@Mixin(GpuSurface.class)
30
public abstract class GpuSurfaceMixin {
31
    /**
32
     * Last safe point before Minecraft copies the main render target into the
33
     * window surface. Combatant submission must be closed before the blit.
34
     */
35
    @Inject(method = "blitFromTexture", at = @At("HEAD"))
36
    private void combatant$beforeSurfaceBlit(CommandEncoder encoder, GpuTextureView textureView, CallbackInfo info) {
37
        CombatantRenderSystem.endRenderSubmission();
38
    }
39
40
    @Inject(method = "present", at = @At("HEAD"))
41
    private void combatant$onPresentHead(CallbackInfo info) {
42
        FastFps.onFrame();
43
        AnimationUtility.onFrame();
44
    }
45
46
    @Redirect(
47
            method = "configure",
48
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuSurfaceBackend;configure(Lcom/mojang/blaze3d/systems/GpuSurface$Configuration;)V")
49
    )
50
    private void combatant$profileSurfaceConfigure(GpuSurfaceBackend backend, GpuSurface.Configuration configuration) throws SurfaceException {
51
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("surface:configure")) {
52
            backend.configure(configuration);
53
        }
54
    }
55
56
    @Redirect(
57
            method = "acquireNextTexture",
58
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuSurfaceBackend;acquireNextTexture()V")
59
    )
60
    private void combatant$profileSurfaceAcquire(GpuSurfaceBackend backend) throws SurfaceException {
61
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("surface:acquire")) {
62
            backend.acquireNextTexture();
63
        }
64
    }
65
66
    @Redirect(
67
            method = "blitFromTexture",
68
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuSurfaceBackend;blitFromTexture(Lcom/mojang/blaze3d/systems/CommandEncoderBackend;Lcom/mojang/blaze3d/textures/GpuTextureView;)V")
69
    )
70
    private void combatant$profileSurfaceBlit(GpuSurfaceBackend backend, CommandEncoderBackend encoder, GpuTextureView textureView) {
71
        try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("surface:blit")) {
72
            backend.blitFromTexture(encoder, textureView);
73
        } catch (RuntimeException | Error failure) {
74
            // A lost/minimized surface can fail before present() is reached. Retire Combatant's
75
            // frame here as well so transient resources and logical frame identity cannot leak.
76
            combatant$finishFrameBoundary();
77
            throw failure;
78
        }
79
    }
80
81
    @Redirect(
82
            method = "present",
83
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/GpuSurfaceBackend;present()V")
84
    )
85
    private void combatant$profileSurfacePresent(GpuSurfaceBackend backend) {
86
        try {
87
            try (ProfilerPhase.Scope ignored = ProfilerPhase.scope("surface:present")) {
88
                backend.present();
89
            }
90
        } finally {
91
            // Surface loss/minimize may throw out of backend.present(). Combatant must still retire
92
            // the logical frame or the next world render reuses stale frame id/uniform/transient state.
93
            combatant$finishFrameBoundary();
94
        }
95
    }
96
97
    private void combatant$finishFrameBoundary() {
98
        if (TracyGpuProfiler.isEnabled()) {
99
            TracyGpuProfiler.onFrameEnd();
100
        }
101
        CombatantRenderSystem.onFramePresented();
102
        Renderer2D.getBatchStats().onFrameStart();
103
        UiBlurResources.invalidateWorldSource();
104
    }
105
}
106
GuiGraphicsMixinsrc/main/java/combatant/client/mixins/GuiGraphicsMixin.javaJava · 234 lines · 9.2 KB
@Mixin(GuiGraphicsExtractor.class)
GuiGraphicsMixin.javaJava · 234 lines · 9.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
14
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
15
import net.minecraft.client.renderer.RenderPipelines;
16
import net.minecraft.util.Mth;
17
import net.minecraft.world.item.ItemStack;
18
import net.minecraft.world.item.Items;
19
import org.joml.Matrix3x2fStack;
20
import org.spongepowered.asm.mixin.Final;
21
import org.spongepowered.asm.mixin.Mixin;
22
import org.spongepowered.asm.mixin.Unique;
23
import org.spongepowered.asm.mixin.Shadow;
24
import org.spongepowered.asm.mixin.gen.Invoker;
25
import org.spongepowered.asm.mixin.injection.At;
26
import org.spongepowered.asm.mixin.injection.Inject;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
import combatant.client.features.gui.hud.CooldownRender;
29
import combatant.client.features.gui.hud.nondraggable.impl.BetterTooltips;
30
import combatant.client.features.module.Modules;
31
import combatant.client.features.module.modules.combat.PvpCooldowns;
32
import combatant.client.mixininterface.IGuiGraphics;
33
import combatant.client.render.engine.core.ViewportContext;
34
import combatant.client.render.engine.renderer.Renderer2D;
35
import combatant.client.render.engine.renderer.ui.HudDeferredGuiElement;
36
import net.minecraft.client.gui.navigation.ScreenRectangle;
37
import net.minecraft.client.renderer.state.gui.GuiRenderState;
38
import combatant.client.util.pvp.CooldownRegistry;
39
import combatant.client.util.pvp.ItemCooldownSnapshot;
40
import combatant.client.util.pvp.PvpState;
41
import combatant.client.util.pvp.client.CooldownsState;
42
43
@Mixin(GuiGraphicsExtractor.class)
44
public abstract class GuiGraphicsMixin implements IGuiGraphics {
45
    @Final
46
    @Shadow
47
    private Matrix3x2fStack pose;
48
49
    @Final
50
    @Shadow
51
    public GuiRenderState guiRenderState;
52
53
    @Shadow
54
    public abstract int guiWidth();
55
56
    @Shadow
57
    public abstract int guiHeight();
58
59
    @Override
60
    public void combatant$runUnscaled(Runnable task) {
61
        Minecraft mc = Minecraft.getInstance();
62
        double scale = mc.getWindow().getGuiScale();
63
        double uiScale = ViewportContext.getUiScale();
64
        float ratio = (float) (uiScale / scale);
65
        pose.scale(ratio, ratio);
66
        try {
67
            task.run();
68
        } finally {
69
            pose.scale((float) (scale / uiScale), (float) (scale / uiScale));
70
        }
71
    }
72
73
    @Override
74
    public void combatant$withTransform(float tx, float ty, float angleRad, Runnable task) {
75
        pose.pushMatrix();
76
        try {
77
            pose.translate(tx, ty);
78
            pose.rotate(angleRad);
79
            task.run();
80
        } finally {
81
            pose.popMatrix();
82
        }
83
    }
84
85
    @Override
86
    public void combatant$addDeferredHudMarker(Renderer2D.Deferred2DLayer layer) {
87
        if (layer == null || guiRenderState == null) return;
88
        int width = Math.max(1, guiWidth());
89
        int height = Math.max(1, guiHeight());
90
        guiRenderState.addGlyphToCurrentLayer(new HudDeferredGuiElement(layer, new ScreenRectangle(0, 0, width, height)));
91
    }
92
93
    @Override
94
    public void combatant$drawItemBar(ItemStack stack, int x, int y) {
95
        combatant$invokeDrawItemBar(stack, x, y);
96
    }
97
98
    @Override
99
    public void combatant$drawCooldownProgress(ItemStack stack, int x, int y) {
100
        combatant$invokeDrawCooldownProgress(stack, x, y);
101
    }
102
103
    @Invoker("itemBar")
104
    public abstract void combatant$invokeDrawItemBar(ItemStack stack, int x, int y);
105
106
    @Invoker("itemCooldown")
107
    public abstract void combatant$invokeDrawCooldownProgress(ItemStack stack, int x, int y);
108
109
    @Unique
110
    private ItemStack combatant$tooltipStackContext = ItemStack.EMPTY;
111
112
    @Inject(
113
            method = "setTooltipForNextFrame(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V",
114
            at = @At("HEAD")
115
    )
116
    private void combatant$beginItemTooltipContext(net.minecraft.client.gui.Font font,
117
                                                   ItemStack stack,
118
                                                   int x, int y,
119
                                                   CallbackInfo ci) {
120
        combatant$tooltipStackContext = stack != null ? stack : ItemStack.EMPTY;
121
    }
122
123
    @Inject(
124
            method = "setTooltipForNextFrame(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V",
125
            at = @At("RETURN")
126
    )
127
    private void combatant$endItemTooltipContext(net.minecraft.client.gui.Font font,
128
                                                 ItemStack stack,
129
                                                 int x, int y,
130
                                                 CallbackInfo ci) {
131
        combatant$tooltipStackContext = ItemStack.EMPTY;
132
    }
133
134
    @Inject(method = "setTooltipForNextFrameInternal", at = @At("HEAD"), cancellable = true)
135
    private void combatant$captureTooltipGlobally(net.minecraft.client.gui.Font font,
136
                                                  java.util.List<ClientTooltipComponent> components,
137
                                                  int x, int y,
138
                                                  ClientTooltipPositioner positioner,
139
                                                  net.minecraft.resources.Identifier style,
140
                                                  boolean replaceExisting,
141
                                                  CallbackInfo ci) {
142
        ItemStack stack = combatant$tooltipStackContext;
143
        if (stack == null || stack.isEmpty()) {
144
            ItemStack inferred = BetterTooltips.consumeLastTooltipStack();
145
            if (BetterTooltips.matchesItemTooltip(components, inferred)) {
146
                stack = inferred;
147
            }
148
        }
149
        if (BetterTooltips.captureTooltipComponents(
150
                components,
151
                positioner,
152
                x, y,
153
                stack != null ? stack : ItemStack.EMPTY,
154
                (GuiGraphicsExtractor) (Object) this,
155
                replaceExisting
156
        )) {
157
            ci.cancel();
158
        }
159
    }
160
161
    @Inject(method = "itemCooldown", at = @At("HEAD"), cancellable = true)
162
    private void combatant$renderCustomPvpCooldown(ItemStack stack, int x, int y, CallbackInfo ci) {
163
        if (stack.isEmpty()) return;
164
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
165
        if (cooldowns == null || !cooldowns.isSystemEnabled()) return;
166
167
        if (stack.is(Items.ENDER_PEARL) || stack.is(Items.CHORUS_FRUIT)) {
168
            if (!PvpState.isActive()) return;
169
            Float secondsLeft = PvpState.getSecondsLeft();
170
            if (secondsLeft == null || secondsLeft <= 0f) return;
171
            Float maxSeconds = PvpState.getMaxSeconds();
172
            float total = (maxSeconds == null || maxSeconds <= 0f) ? secondsLeft : maxSeconds;
173
            float progress = Mth.clamp(secondsLeft / total, 0f, 1f);
174
175
            Minecraft mc = Minecraft.getInstance();
176
            GuiGraphicsExtractor ctx = (GuiGraphicsExtractor) (Object) this;
177
178
            float secondsLeftValue = secondsLeft;
179
            float displaySeconds = secondsLeftValue >= 10f
180
                    ? (float) ((int) secondsLeftValue)
181
                    : Math.round(secondsLeftValue * 10f) / 10f;
182
183
            int top = y + Mth.floor(16.0F * (1.0F - progress));
184
            int bottom = top + Mth.ceil(16.0F * progress);
185
186
            int color = 0x80FF5656;
187
            ctx.fill(RenderPipelines.GUI, x, top, x + 16, bottom, color);
188
189
            CooldownRender.renderTime(
190
                    ctx, progress, x, y, displaySeconds
191
            );
192
193
            if (ClientScreen.current() == null) {
194
                ci.cancel();
195
            }
196
            return;
197
        }
198
199
        if (!cooldowns.shouldRenderSlots()) return;
200
        if (!CooldownRegistry.isTracked(stack.getItem())) return;
201
202
        ItemCooldownSnapshot snapshot = CooldownsState.MANAGER.snapshot(stack.getItem());
203
        if (!snapshot.visible()) return;
204
205
        Minecraft mc = Minecraft.getInstance();
206
        GuiGraphicsExtractor ctx = (GuiGraphicsExtractor) (Object) this;
207
208
        float progress = snapshot.cooling() ? snapshot.cooldownProgress() : snapshot.usesProgress();
209
        if (progress <= 0f) return;
210
211
        float secondsLeft = snapshot.cooling() ? snapshot.cooldownRemainingMs() / 1000.0f : snapshot.useWindowRemainingMs() / 1000.0f;
212
        float displaySeconds = snapshot.cooling()
213
                ? (secondsLeft >= 10 ? (float) ((int) secondsLeft) : Math.round(secondsLeft * 10f) / 10f)
214
                : 0f;
215
216
        int top = y + Mth.floor(16.0F * (1.0F - progress));
217
        int bottom = top + Mth.ceil(16.0F * progress);
218
219
        int color = snapshot.cooling()
220
                ? (CooldownsState.MANAGER.isInPvp() ? 0x80FFA500 : 0x8000A0FF)
221
                : 0x706D9DFF;
222
223
        ctx.fill(RenderPipelines.GUI, x, top, x + 16, bottom, color);
224
225
        if (snapshot.cooling()) {
226
            CooldownRender.renderTime(ctx, progress, x, y, displaySeconds);
227
        }
228
229
        if (ClientScreen.current() == null) {
230
            ci.cancel();
231
        }
232
    }
233
}
234
GuiMixinsrc/main/java/combatant/client/mixins/GuiMixin.javaJava · 429 lines · 18.2 KB
@Mixin(Hud.class)
ModifiesHud
GuiMixin.javaJava · 429 lines · 18.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.DeltaTracker;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.Hud;
14
import net.minecraft.client.player.LocalPlayer;
15
import net.minecraft.core.Holder;
16
import net.minecraft.network.chat.Component;
17
import net.minecraft.network.chat.MutableComponent;
18
import net.minecraft.world.entity.Entity;
19
import net.minecraft.world.entity.ai.attributes.Attribute;
20
import net.minecraft.world.entity.ai.attributes.Attributes;
21
import net.minecraft.world.entity.player.Player;
22
import net.minecraft.world.scores.Objective;
23
import org.spongepowered.asm.mixin.Final;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.Unique;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.Redirect;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
import combatant.client.events.Events;
32
import combatant.client.events.impl.PvpOverlayEvent;
33
import combatant.client.features.gui.hud.draggable.DraggableHudElementRegistry;
34
import combatant.client.features.gui.hud.draggable.impl.Potions;
35
import combatant.client.features.gui.hud.draggable.impl.Scoreboard;
36
import combatant.client.features.gui.hud.nondraggable.impl.SwapTooltip;
37
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
38
import combatant.client.features.gui.hud.nondraggable.impl.CustomHealthBar;
39
import combatant.client.features.gui.hud.nondraggable.impl.CustomHotbar;
40
import combatant.client.features.module.Modules;
41
import combatant.client.features.module.modules.misc.MessageFilter;
42
import combatant.client.features.module.modules.visuals.Crosshair;
43
import combatant.client.features.module.modules.visuals.NoRender;
44
import combatant.client.mixininterface.IGuiGraphics;
45
import combatant.client.render.engine.core.CombatantRenderSystem;
46
import combatant.client.render.engine.core.RenderPhase;
47
import combatant.client.render.engine.core.RenderPhaseScope;
48
import combatant.client.render.engine.core.ViewportContext;
49
// import combatant.client.render.engine.debug.RenderThread2DDebugRenderer; // disabled: debug probes are manual-only
50
import combatant.client.render.engine.renderer.Renderer2D;
51
import combatant.client.runtime.RuntimeGate;
52
import combatant.client.util.item.IllegalItemUtil;
53
import combatant.client.util.item.RarityColorUtil;
54
import combatant.client.util.item.TopEnchantUtil;
55
import combatant.client.util.logging.DebugLog;
56
import combatant.client.util.text.TextJsonUtil;
57
58
@Mixin(Hud.class)
59
public abstract class GuiMixin {
60
61
62
    @Shadow
63
    private int toolHighlightTimer;
64
    @Shadow
65
    private net.minecraft.world.item.ItemStack lastToolHighlight;
66
    @Shadow
67
    @Final
68
    private Minecraft minecraft;
69
70
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V", at = @At("TAIL"))
71
    private void combatant$debug2dGuiStateProbe(GuiGraphicsExtractor ctx, DeltaTracker tickCounter, CallbackInfo ci) {
72
    }
73
74
    @Unique
75
    private static void combatant$renderCustomBarOnly(GuiGraphicsExtractor ctx,
76
                                                      DeltaTracker tickCounter,
77
                                                      Minecraft mc,
78
                                                      CustomBar bar) {
79
        boolean useJump = CustomBar.shouldUseJumpBar(mc);
80
        boolean useLocator = !useJump && CustomBar.shouldUseLocator(mc, bar);
81
        boolean drawXp = !useJump && !useLocator;
82
83
        CombatantRenderSystem.ensureFrameContext();
84
        try (RenderPhaseScope ignored = CombatantRenderSystem.phase(RenderPhase.HUD_MAIN, "2d:hud:custom_bar")) {
85
            Renderer2D.withDeferredLayer(COMBATANT$VANILLA_HUD_REPLACEMENT_LAYER, () -> {
86
                ViewportContext.beginUnscaled(ctx);
87
                Renderer2D.COLOR.begin();
88
                if (drawXp) {
89
                    CustomBar.renderXpBarBackground(Renderer2D.COLOR, mc);
90
                }
91
                if (useJump) {
92
                    CustomBar.renderJumpBarBackground(Renderer2D.COLOR, mc);
93
                }
94
                if (useLocator) {
95
                    CustomBar.renderLocatorBackground(Renderer2D.COLOR, mc);
96
                }
97
                Renderer2D.COLOR.render();
98
                ViewportContext.end(ctx);
99
100
                if (drawXp) {
101
                    CustomBar.renderXpBarText(ctx, mc);
102
                }
103
            });
104
            combatant$appendVanillaHudReplacementMarker(ctx);
105
        }
106
    }
107
108
    @Unique
109
    private static final Renderer2D.Deferred2DLayer COMBATANT$VANILLA_HUD_REPLACEMENT_LAYER =
110
            Renderer2D.Deferred2DLayer.HUD_AFTER_MISC_OVERLAYS;
111
112
    @Unique
113
    private static void combatant$appendVanillaHudReplacementMarker(GuiGraphicsExtractor ctx) {
114
        if (!(ctx instanceof IGuiGraphics graphics)) return;
115
        ctx.nextStratum();
116
        graphics.combatant$addDeferredHudMarker(COMBATANT$VANILLA_HUD_REPLACEMENT_LAYER);
117
        ctx.nextStratum();
118
    }
119
120
    @Unique
121
    private static int argbFrom(float[] rgba) {
122
        if (rgba == null || rgba.length < 3) return 0xFFFFFFFF;
123
        float r = rgba[0], g = rgba[1], b = rgba[2];
124
        float a = rgba.length > 3 ? rgba[3] : 1f;
125
        int ai = (int) (a * 255) & 0xFF;
126
        int ri = (int) (r * 255) & 0xFF;
127
        int gi = (int) (g * 255) & 0xFF;
128
        int bi = (int) (b * 255) & 0xFF;
129
        return (ai << 24) | (ri << 16) | (gi << 8) | bi;
130
    }
131
132
    @Inject(
133
            method = "displayScoreboardSidebar(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/world/scores/Objective;)V",
134
            at = @At("HEAD"),
135
            cancellable = true
136
    )
137
    private void combatant$hideScoreboardSidebar(GuiGraphicsExtractor context, Objective objective, CallbackInfo ci) {
138
        if (RuntimeGate.isPanic()) return;
139
        NoRender noRender = Modules.get(NoRender.class);
140
        if ((noRender != null && noRender.hideScoreboard()) || Scoreboard.shouldReplaceVanilla()) {
141
            ci.cancel();
142
        }
143
    }
144
145
    @Inject(
146
            method = "setOverlayMessage(Lnet/minecraft/network/chat/Component;Z)V",
147
            at = @At("HEAD"),
148
            cancellable = true
149
    )
150
    private void combatant$filterOverlayMessage(net.minecraft.network.chat.Component message, boolean tinted, CallbackInfo ci) {
151
        if (DebugLog.serverOnly()) {
152
            if (message == null) {
153
            } else {
154
                String raw = message.getString();
155
                String json = TextJsonUtil.toJson(message);
156
            }
157
        }
158
        if (Events.BUS.hasListeners(PvpOverlayEvent.class)) {
159
            Events.BUS.post(new PvpOverlayEvent(message, tinted));
160
        }
161
        if (RuntimeGate.isPanic()) return;
162
        MessageFilter messageFilter = Modules.get(MessageFilter.class);
163
        if (messageFilter != null && messageFilter.shouldHideHud(message)) {
164
            ci.cancel();
165
        }
166
    }
167
168
    @Inject(
169
            method = "extractEffects(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
170
            at = @At("HEAD"),
171
            cancellable = true
172
    )
173
    private void combatant$hideVanillaPotions(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
174
        if (RuntimeGate.isPanic()) return;
175
        Minecraft mc = Minecraft.getInstance();
176
        if (mc == null || mc.player == null) return;
177
        if (!DraggableHudElementRegistry.isEnabled(Potions.class)) return;
178
        if (mc.player.getActiveEffects().isEmpty()) return;
179
        ci.cancel();
180
    }
181
182
183
    @Inject(
184
            method = "extractCrosshair(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
185
            at = @At("HEAD"),
186
            cancellable = true
187
    )
188
    private void combatant$replaceCrosshair(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
189
        if (RuntimeGate.isPanic()) return;
190
        Crosshair crosshair = Modules.get(Crosshair.class);
191
        if (crosshair != null && crosshair.shouldHideVanilla()) {
192
            ci.cancel();
193
        }
194
    }
195
196
    @Inject(
197
            method = "extractVignette(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/world/entity/Entity;)V",
198
            at = @At("HEAD"),
199
            cancellable = true
200
    )
201
    private void combatant$killVignette(GuiGraphicsExtractor context, Entity entity, CallbackInfo ci) {
202
        if (RuntimeGate.isPanic()) return;
203
        // Completely remove vanilla vignette post-processing
204
        ci.cancel();
205
    }
206
207
    @Inject(
208
            method = "extractItemHotbar(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
209
            at = @At("HEAD"),
210
            cancellable = true
211
    )
212
    private void combatant$customHotbar(GuiGraphicsExtractor ctx, DeltaTracker tickCounter, CallbackInfo ci) {
213
        if (RuntimeGate.isPanic()) return;
214
        Minecraft mc = Minecraft.getInstance();
215
        if (mc == null || mc.player == null) return;
216
217
        CustomHotbar hotbar = CustomHotbar.get();
218
        CustomBar bar = CustomBar.get();
219
        if (hotbar == null && bar == null) return;
220
221
        boolean hotbarEnabled = hotbar != null && hotbar.isHudHotbarEnabled();
222
        boolean barEnabled = bar != null && bar.isHudBarEnabled() && bar.isHotbarXpBarEnabled();
223
        if (!hotbarEnabled && !barEnabled) return;
224
        if (!hotbarEnabled) return;
225
226
        boolean useJump = barEnabled && CustomBar.shouldUseJumpBar(mc);
227
        boolean useLocator = barEnabled && !useJump && CustomBar.shouldUseLocator(mc, bar);
228
        boolean drawXp = barEnabled && !useJump && !useLocator;
229
230
        CombatantRenderSystem.ensureFrameContext();
231
        try (RenderPhaseScope ignored = CombatantRenderSystem.phase(RenderPhase.HUD_MAIN, "2d:hud:custom_hotbar")) {
232
            Renderer2D.withDeferredLayer(COMBATANT$VANILLA_HUD_REPLACEMENT_LAYER, () -> {
233
                ViewportContext.beginUnscaled(ctx);
234
                Renderer2D.COLOR.begin();
235
                if (hotbarEnabled) {
236
                    CustomHotbar.renderBackground(Renderer2D.COLOR, mc);
237
                }
238
                if (drawXp) {
239
                    CustomBar.renderXpBarBackground(Renderer2D.COLOR, mc);
240
                }
241
                if (barEnabled && useJump) {
242
                    CustomBar.renderJumpBarBackground(Renderer2D.COLOR, mc);
243
                }
244
                if (barEnabled && useLocator) {
245
                    CustomBar.renderLocatorBackground(Renderer2D.COLOR, mc);
246
                }
247
                Renderer2D.COLOR.render();
248
                ViewportContext.end(ctx);
249
250
                if (hotbarEnabled) {
251
                    CustomHotbar.renderItems(ctx, tickCounter, mc);
252
                }
253
            });
254
            combatant$appendVanillaHudReplacementMarker(ctx);
255
256
            if (drawXp) {
257
                CustomBar.renderXpBarText(ctx, mc);
258
            }
259
            if (hotbarEnabled) {
260
                ci.cancel();
261
            }
262
        }
263
    }
264
265
    @Inject(
266
            method = "extractItemHotbar(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
267
            at = @At("TAIL")
268
    )
269
    private void combatant$customBarAfterVanillaHotbar(GuiGraphicsExtractor ctx, DeltaTracker tickCounter, CallbackInfo ci) {
270
        if (RuntimeGate.isPanic()) return;
271
        Minecraft mc = Minecraft.getInstance();
272
        if (mc == null || mc.player == null) return;
273
274
        CustomHotbar hotbar = CustomHotbar.get();
275
        if (hotbar != null && hotbar.isHudHotbarEnabled()) return;
276
277
        CustomBar bar = CustomBar.get();
278
        if (bar == null || !bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
279
280
        combatant$renderCustomBarOnly(ctx, tickCounter, mc, bar);
281
    }
282
283
    @Inject(
284
            method = "extractPortalOverlay(Lnet/minecraft/client/gui/GuiGraphicsExtractor;F)V",
285
            at = @At("HEAD"),
286
            cancellable = true
287
    )
288
    private void combatant$disableVanillaPortalOverlay(GuiGraphicsExtractor context, float nauseaStrength, CallbackInfo ci) {
289
        if (RuntimeGate.isPanic()) return;
290
        ci.cancel();
291
    }
292
293
    @Inject(
294
            method = "extractSleepOverlay(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
295
            at = @At("HEAD"),
296
            cancellable = true
297
    )
298
    private void combatant$disableVanillaSleepOverlay(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
299
        if (RuntimeGate.isPanic()) return;
300
        ci.cancel();
301
    }
302
303
    @Inject(
304
            method = "extractHearts(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/world/entity/player/Player;IIIIFIIIZ)V",
305
            at = @At("HEAD"),
306
            cancellable = true
307
    )
308
    private void combatant$renderHealthBar(GuiGraphicsExtractor context,
309
                                           Player player,
310
                                           int x, int y, int lines,
311
                                           int regeneratingHeartIndex, float maxHealth,
312
                                           int lastHealth, int health,
313
                                           int absorption, boolean blinking,
314
                                           CallbackInfo ci) {
315
        if (!RuntimeGate.canRunHud()) return;
316
        if (!(player instanceof LocalPlayer clientPlayer)) return;
317
        Minecraft mc = Minecraft.getInstance();
318
        if (mc == null) return;
319
320
        if (!CustomHealthBar.shouldRenderHealthBar(mc, clientPlayer, maxHealth)) return;
321
322
        CombatantRenderSystem.ensureFrameContext();
323
        try (RenderPhaseScope ignored = CombatantRenderSystem.phase(RenderPhase.HUD_MAIN, "2d:hud:custom_health")) {
324
            Renderer2D.withDeferredLayer(COMBATANT$VANILLA_HUD_REPLACEMENT_LAYER, () -> {
325
                ViewportContext.beginUnscaled(context);
326
                Renderer2D.COLOR.begin();
327
                CustomHealthBar.HealthTextInfo textInfo =
328
                        CustomHealthBar.renderHealthBarBackground(
329
                                Renderer2D.COLOR,
330
                                mc,
331
                                clientPlayer,
332
                                x,
333
                                y,
334
                                maxHealth
335
                        );
336
                CustomHealthBar.renderHealthBarText(textInfo);
337
                Renderer2D.COLOR.render();
338
                ViewportContext.end(context);
339
            });
340
            combatant$appendVanillaHudReplacementMarker(context);
341
            ci.cancel();
342
        }
343
    }
344
345
    @Inject(method = "extractSelectedItemName", at = @At("HEAD"), cancellable = true)
346
    private void combatant$colorizeHeldItemTooltip(GuiGraphicsExtractor context, CallbackInfo ci) {
347
        if (!RuntimeGate.canRunHud()) return;
348
        SwapTooltip swapTooltip = SwapTooltip.get();
349
        if (swapTooltip == null || !swapTooltip.isEnabled()) {
350
            return;
351
        }
352
        if (this.toolHighlightTimer <= 0 || this.lastToolHighlight == null || this.lastToolHighlight.isEmpty()) {
353
            SwapTooltip.clear();
354
            return;
355
        }
356
357
        MutableComponent name = Component.empty().append(this.lastToolHighlight.getHoverName());
358
        if (this.lastToolHighlight.has(net.minecraft.core.component.DataComponents.CUSTOM_NAME)) {
359
            name.withStyle(net.minecraft.ChatFormatting.ITALIC);
360
        }
361
362
        int illegalColor = IllegalItemUtil.illegalColor();
363
        int topColor = TopEnchantUtil.topColor();
364
        int rarityColor = argbFrom(RarityColorUtil.INSTANCE.getRarityColor(this.lastToolHighlight));
365
        boolean hasIllegal = IllegalItemUtil.isIllegal(this.lastToolHighlight);
366
        boolean hasTop = !hasIllegal && TopEnchantUtil.hasTopEnchant(this.lastToolHighlight);
367
        int nameColor = hasIllegal ? illegalColor : (hasTop ? topColor : rarityColor);
368
        int alpha = (int) ((float) this.toolHighlightTimer * 256.0F / 10.0F);
369
        if (alpha > 255) alpha = 255;
370
        if (alpha <= 0) {
371
            SwapTooltip.clear();
372
            return;
373
        }
374
        float fade = alpha / 255f;
375
        int argb = 0xFF000000 | (nameColor & 0x00FFFFFF);
376
        SwapTooltip.capture(
377
                name.getString(),
378
                argb,
379
                fade,
380
                this.minecraft.gameMode.canHurtPlayer()
381
        );
382
        ci.cancel();
383
    }
384
385
    @Redirect(
386
            method = "extractPlayerHealth(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V",
387
            at = @At(
388
                    value = "INVOKE",
389
                    target = "Lnet/minecraft/world/entity/player/Player;getAbsorptionAmount()F"
390
            )
391
    )
392
    private float combatant$ignoreAbsorptionForLayout(Player player) {
393
        if (!RuntimeGate.canRunHud()) {
394
            return player.getAbsorptionAmount();
395
        }
396
        Minecraft mc = Minecraft.getInstance();
397
        if (mc != null && player instanceof LocalPlayer clientPlayer) {
398
            float actualMaxHealth = (float) player.getAttributeValue(Attributes.MAX_HEALTH);
399
            if (CustomHealthBar.shouldRenderHealthBar(mc, clientPlayer, actualMaxHealth)) {
400
                return 0.0f;
401
            }
402
        }
403
        return player.getAbsorptionAmount();
404
    }
405
406
    @Redirect(
407
            method = "extractPlayerHealth(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V",
408
            at = @At(
409
                    value = "INVOKE",
410
                    target = "Lnet/minecraft/world/entity/player/Player;getAttributeValue(Lnet/minecraft/core/Holder;)D"
411
            )
412
    )
413
    private double combatant$clampMaxHealthForLayout(Player player, Holder<Attribute> attribute) {
414
        if (!RuntimeGate.canRunHud()) {
415
            return player.getAttributes().getValue(attribute);
416
        }
417
        if (attribute == Attributes.MAX_HEALTH) {
418
            Minecraft mc = Minecraft.getInstance();
419
            if (mc != null && player instanceof LocalPlayer clientPlayer) {
420
                float actualMaxHealth = (float) player.getAttributes().getValue(attribute);
421
                if (CustomHealthBar.shouldRenderHealthBar(mc, clientPlayer, actualMaxHealth)) {
422
                    return 20.0;
423
                }
424
            }
425
        }
426
        return player.getAttributes().getValue(attribute);
427
    }
428
}
429
GuiRendererMixinsrc/main/java/combatant/client/mixins/GuiRendererMixin.javaJava · 264 lines · 9.8 KB
@Mixin(GuiRenderer.class)
ModifiesGuiRenderer
GuiRendererMixin.javaJava · 264 lines · 9.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.ProjectionType;
11
import com.mojang.blaze3d.buffers.GpuBufferSlice;
12
import com.mojang.blaze3d.pipeline.RenderTarget;
13
import com.mojang.blaze3d.systems.RenderSystem;
14
import combatant.client.render.engine.renderer.Renderer2D;
15
import combatant.client.render.engine.renderer.ui.HudDeferredGuiElement;
16
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
17
import net.minecraft.client.Minecraft;
18
import net.minecraft.client.gui.render.GuiRenderer;
19
import net.minecraft.client.renderer.Projection;
20
import net.minecraft.client.renderer.ProjectionMatrixBuffer;
21
import net.minecraft.client.renderer.state.WindowRenderState;
22
import net.minecraft.client.renderer.state.gui.GuiElementRenderState;
23
import net.minecraft.client.renderer.state.gui.GuiRenderState;
24
import org.joml.Matrix4f;
25
import org.spongepowered.asm.mixin.Final;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.Shadow;
28
import org.spongepowered.asm.mixin.Unique;
29
import org.spongepowered.asm.mixin.injection.At;
30
import org.spongepowered.asm.mixin.injection.Inject;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32
33
import java.util.List;
34
import java.util.function.Supplier;
35
36
@Mixin(GuiRenderer.class)
37
public abstract class GuiRendererMixin {
38
    @Shadow
39
    @Final
40
    private List<?> draws;
41
42
    @Shadow
43
    private int firstDrawIndexAfterBlur;
44
45
    @Shadow
46
    @Final
47
    private Projection guiProjection;
48
49
    @Shadow
50
    @Final
51
    private ProjectionMatrixBuffer guiProjectionMatrixBuffer;
52
53
    @Unique
54
    private final ObjectArrayList<QueuedHudMarker> combatant$hudMarkers = new ObjectArrayList<>(16);
55
56
    @Unique
57
    private GuiRenderState.TraverseRange combatant$currentTraverseRange;
58
59
    @Shadow
60
    private void executeDrawRange(Supplier<String> supplier,
61
                                  RenderTarget renderTarget,
62
                                  GpuBufferSlice gpuBufferSlice,
63
                                  int start,
64
                                  int end) {
65
        throw new AssertionError();
66
    }
67
68
    @Inject(method = "render", at = @At("HEAD"))
69
    private void combatant$clearHudMarkersAtFrameStart(CallbackInfo ci) {
70
        combatant$hudMarkers.clear();
71
    }
72
73
    @Inject(method = "render", at = @At("RETURN"))
74
    private void combatant$clearHudMarkersAtFrameEnd(CallbackInfo ci) {
75
        combatant$hudMarkers.clear();
76
    }
77
78
    @Inject(method = "addElementsToMeshes", at = @At("HEAD"))
79
    private void combatant$enterTraverseRange(GuiRenderState.TraverseRange range, CallbackInfo ci) {
80
        combatant$currentTraverseRange = range;
81
    }
82
83
    @Inject(method = "addElementsToMeshes", at = @At("RETURN"))
84
    private void combatant$exitTraverseRange(GuiRenderState.TraverseRange range, CallbackInfo ci) {
85
        combatant$currentTraverseRange = null;
86
    }
87
88
    @Inject(method = "addElementToMesh", at = @At("HEAD"), cancellable = true)
89
    private void combatant$captureHudDeferredMarker(GuiElementRenderState element, CallbackInfo ci) {
90
        if (!(element instanceof HudDeferredGuiElement marker)) return;
91
        int drawIndex = draws != null ? draws.size() : 0;
92
        GuiRenderState.TraverseRange range = combatant$currentTraverseRange != null
93
                ? combatant$currentTraverseRange
94
                : GuiRenderState.TraverseRange.BEFORE_BLUR;
95
        combatant$hudMarkers.add(new QueuedHudMarker(drawIndex, range, marker.layer()));
96
        ci.cancel();
97
    }
98
99
    @Inject(method = "draw", at = @At("HEAD"), cancellable = true)
100
    private void combatant$drawWithDeferredHudMarkers(CallbackInfo ci) {
101
        if (combatant$hudMarkers.isEmpty()) return;
102
103
        if (draws == null || draws.isEmpty()) {
104
            combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
105
            ci.cancel();
106
            return;
107
        }
108
109
        Minecraft mc = Minecraft.getInstance();
110
        if (mc == null || mc.gameRenderer == null) {
111
            combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
112
            ci.cancel();
113
            return;
114
        }
115
116
        WindowRenderState window = mc.gameRenderer.gameRenderState().windowRenderState;
117
        if (window == null || window.guiScale == 0) {
118
            combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
119
            ci.cancel();
120
            return;
121
        }
122
123
        guiProjection.setupOrtho(
124
                1000.0F,
125
                11000.0F,
126
                (float) window.width / (float) window.guiScale,
127
                (float) window.height / (float) window.guiScale,
128
                true
129
        );
130
        RenderSystem.setProjectionMatrix(guiProjectionMatrixBuffer.getBuffer(guiProjection), ProjectionType.ORTHOGRAPHIC);
131
132
        RenderTarget target = mc.gameRenderer.mainRenderTarget();
133
        if (target == null) {
134
            combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
135
            ci.cancel();
136
            return;
137
        }
138
139
        GpuBufferSlice transform = RenderSystem.getDynamicUniforms()
140
                .writeTransform(new Matrix4f().setTranslation(0.0F, 0.0F, -11000.0F));
141
142
        int beforeBlurEnd = Math.min(firstDrawIndexAfterBlur, draws.size());
143
        if (beforeBlurEnd > 0) {
144
            combatant$executeDrawRangeWithHudMarkers(
145
                    () -> "gui before blur",
146
                    target,
147
                    transform,
148
                    0,
149
                    beforeBlurEnd,
150
                    GuiRenderState.TraverseRange.BEFORE_BLUR
151
            );
152
        } else {
153
            combatant$drainHudMarkersInRange(GuiRenderState.TraverseRange.BEFORE_BLUR, Integer.MAX_VALUE);
154
        }
155
156
        boolean hasAfterBlurMarkers = combatant$hasPendingHudMarkersInRange(GuiRenderState.TraverseRange.AFTER_BLUR);
157
        if (draws.size() <= firstDrawIndexAfterBlur && !hasAfterBlurMarkers) {
158
            combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
159
            ci.cancel();
160
            return;
161
        }
162
163
        RenderSystem.getDevice().createCommandEncoder().clearDepthTexture(target.getDepthTexture(), 0.0D);
164
        mc.gameRenderer.processBlurEffect();
165
        combatant$executeDrawRangeWithHudMarkers(
166
                () -> "gui after blur",
167
                target,
168
                transform,
169
                firstDrawIndexAfterBlur,
170
                draws.size(),
171
                GuiRenderState.TraverseRange.AFTER_BLUR
172
        );
173
        combatant$drainHudMarkersUpTo(Integer.MAX_VALUE);
174
        ci.cancel();
175
    }
176
177
    @Unique
178
    private void combatant$executeDrawRangeWithHudMarkers(Supplier<String> label,
179
                                                          RenderTarget target,
180
                                                          GpuBufferSlice transform,
181
                                                          int start,
182
                                                          int end,
183
                                                          GuiRenderState.TraverseRange range) {
184
        int cursor = start;
185
        for (int i = 0, size = combatant$hudMarkers.size(); i < size; i++) {
186
            QueuedHudMarker marker = combatant$hudMarkers.get(i);
187
            if (marker == null || marker.drained || marker.range != range) continue;
188
189
            int markerIndex = marker.drawIndex;
190
            if (markerIndex < start) {
191
                combatant$drainHudMarker(marker);
192
                continue;
193
            }
194
            if (markerIndex > end) continue;
195
196
            if (cursor < markerIndex) {
197
                executeDrawRange(label, target, transform, cursor, markerIndex);
198
            }
199
            combatant$drainHudMarker(marker);
200
            cursor = Math.max(cursor, markerIndex);
201
        }
202
203
        if (cursor < end) {
204
            executeDrawRange(label, target, transform, cursor, end);
205
        }
206
    }
207
208
    @Unique
209
    private boolean combatant$hasPendingHudMarkersInRange(GuiRenderState.TraverseRange range) {
210
        for (int i = 0, size = combatant$hudMarkers.size(); i < size; i++) {
211
            QueuedHudMarker marker = combatant$hudMarkers.get(i);
212
            if (marker != null && !marker.drained && marker.range == range) {
213
                return true;
214
            }
215
        }
216
        return false;
217
    }
218
219
    @Unique
220
    private void combatant$drainHudMarkersInRange(GuiRenderState.TraverseRange range, int drawIndexInclusive) {
221
        for (int i = 0, size = combatant$hudMarkers.size(); i < size; i++) {
222
            QueuedHudMarker marker = combatant$hudMarkers.get(i);
223
            if (marker == null || marker.drained || marker.range != range) continue;
224
            if (marker.drawIndex <= drawIndexInclusive) {
225
                combatant$drainHudMarker(marker);
226
            }
227
        }
228
    }
229
230
    @Unique
231
    private void combatant$drainHudMarkersUpTo(int drawIndexInclusive) {
232
        for (int i = 0, size = combatant$hudMarkers.size(); i < size; i++) {
233
            QueuedHudMarker marker = combatant$hudMarkers.get(i);
234
            if (marker == null || marker.drained) continue;
235
            if (marker.drawIndex <= drawIndexInclusive) {
236
                combatant$drainHudMarker(marker);
237
            }
238
        }
239
    }
240
241
    @Unique
242
    private void combatant$drainHudMarker(QueuedHudMarker marker) {
243
        if (marker == null || marker.drained) return;
244
        marker.drained = true;
245
        Renderer2D.drainDeferred2D(marker.layer);
246
    }
247
248
    @Unique
249
    private static final class QueuedHudMarker {
250
        private final int drawIndex;
251
        private final GuiRenderState.TraverseRange range;
252
        private final Renderer2D.Deferred2DLayer layer;
253
        private boolean drained;
254
255
        private QueuedHudMarker(int drawIndex,
256
                                GuiRenderState.TraverseRange range,
257
                                Renderer2D.Deferred2DLayer layer) {
258
            this.drawIndex = drawIndex;
259
            this.range = range;
260
            this.layer = layer;
261
        }
262
    }
263
}
264
GuiScreenMixinsrc/main/java/combatant/client/mixins/GuiScreenMixin.javaJava · 119 lines · 5.2 KB
@Mixin(Gui.class)
ModifiesGui
GuiScreenMixin.javaJava · 119 lines · 5.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import combatant.client.features.module.ModuleManager;
12
import combatant.client.util.screen.ClientScreen;
13
import net.minecraft.client.DeltaTracker;
14
import net.minecraft.client.Minecraft;
15
import net.minecraft.client.gui.Gui;
16
import net.minecraft.client.gui.GuiGraphicsExtractor;
17
import net.minecraft.client.gui.screens.Screen;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Unique;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23
import combatant.client.features.gui.clickgui.ClickGuiEditorScreen;
24
import combatant.client.features.gui.clickgui.ClickGuiPickerScreen;
25
import combatant.client.features.gui.clickgui.ClickGuiRenderer;
26
import combatant.client.features.gui.clickgui.ClickGuiScreen;
27
import combatant.client.features.gui.preview.VisualPreviewRenderer;
28
import combatant.client.features.gui.preview.VisualPreviewRuntime;
29
import combatant.client.features.gui.preview.VisualPreviewScreen;
30
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
31
import combatant.client.features.gui.hud.nondraggable.impl.DynamicIsland;
32
import combatant.client.features.gui.hud.nondraggable.impl.DebugHudReplacement;
33
import combatant.client.features.module.modules.misc.ClickGui;
34
import combatant.client.render.engine.core.CombatantRenderSystem;
35
import combatant.client.render.engine.core.RenderPhase;
36
import combatant.client.render.engine.core.RenderPhaseScope;
37
import combatant.client.render.engine.renderer.Renderer2D;
38
39
@Mixin(Gui.class)
40
public abstract class GuiScreenMixin {
41
42
    @Unique
43
    private static void combatant$extractCustomBarHeads(GuiGraphicsExtractor drawContext, DeltaTracker tickCounter) {
44
        Minecraft mc = Minecraft.getInstance();
45
        if (mc == null || mc.player == null) return;
46
        if (ClientScreen.current() != null) return;
47
48
        CustomBar bar = CustomBar.get();
49
        if (bar == null || !bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
50
        if (CustomBar.shouldUseJumpBar(mc) || !CustomBar.shouldUseLocator(mc, bar)) return;
51
52
        CombatantRenderSystem.ensureFrameContext();
53
        try (RenderPhaseScope ignored = CombatantRenderSystem.phase(RenderPhase.SCREEN_TOP, "2d:hud:custom_bar_heads")) {
54
            Renderer2D.withDeferredLayer(Renderer2D.Deferred2DLayer.AFTER_VANILLA_GUI, () -> {
55
                CustomBar.renderLocatorHeads(drawContext, tickCounter, mc);
56
                Renderer2D.COLOR.render();
57
            });
58
        }
59
    }
60
61
    @Inject(method = "setScreen", at = @At("HEAD"))
62
    private void combatant$closeClickGuiOnScreen(Screen screen, CallbackInfo ci) {
63
        if (!ModuleManager.isEnabled("clickgui")) {
64
            return;
65
        }
66
67
        // A real replacement screen (especially DeathScreen) must always win over ClickGUI input.
68
        // Keeping the module alive while waiting for a bind makes MouseMixin consume that screen's
69
        // clicks, including the respawn button.
70
        if (ClickGuiRenderer.waitingForKey && screen == null) {
71
            return;
72
        }
73
74
        if (screen instanceof ClickGuiScreen
75
                || screen instanceof ClickGuiPickerScreen
76
                || screen instanceof ClickGuiEditorScreen
77
                || screen instanceof VisualPreviewScreen) {
78
            return;
79
        }
80
81
        if (screen != null) {
82
            ClickGui.setSuppressScreenClose(true);
83
            try {
84
                ModuleManager.setEnabled("clickgui", false);
85
            } finally {
86
                ClickGui.setSuppressScreenClose(false);
87
                // Gui#setScreen replaces one non-null screen with another, so vanilla assumes the
88
                // cursor is already released. ClickGUI's immediate shutdown disables it; restore
89
                // the normal screen cursor explicitly for DeathScreen and every other GUI.
90
                ClickGuiRenderer.ensureCursorShown();
91
            }
92
        }
93
    }
94
95
    @Inject(
96
            method = "extractRenderState",
97
            at = @At(
98
                    value = "INVOKE",
99
                    target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;applyCursor(Lcom/mojang/blaze3d/platform/Window;)V"
100
            )
101
    )
102
    private void combatant$extractTopLayer(DeltaTracker tickCounter, boolean renderLevel, boolean renderScreens, CallbackInfo ci,
103
                                           @Local(ordinal = 0) GuiGraphicsExtractor drawContext) {
104
        if (drawContext == null) {
105
            return;
106
        }
107
108
        drawContext.nextStratum();
109
        combatant$extractCustomBarHeads(drawContext, tickCounter);
110
        VisualPreviewRenderer.renderTopLayer(drawContext, tickCounter.getGameTimeDeltaTicks());
111
        DynamicIsland.renderScreenOverlay(drawContext, tickCounter.getGameTimeDeltaTicks());
112
        if (!VisualPreviewRuntime.isActive()) {
113
            ClickGuiRenderer.renderTopLayer(drawContext, tickCounter.getGameTimeDeltaTicks());
114
        }
115
        DebugHudReplacement.renderTopLayer(drawContext);
116
    }
117
118
}
119
HoneyBlockMixinsrc/main/java/combatant/client/mixins/HoneyBlockMixin.javaJava · 38 lines · 1.2 KB
@Mixin(HoneyBlock.class)
ModifiesHoneyBlock
HoneyBlockMixin.javaJava · 38 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.world.entity.Entity;
11
import net.minecraft.world.level.block.HoneyBlock;
12
import net.minecraft.world.phys.Vec3;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Redirect;
16
import combatant.client.util.player.EnvironmentMovementController;
17
18
@Mixin(HoneyBlock.class)
19
public class HoneyBlockMixin {
20
21
    @Redirect(
22
            method = "doSlideMovement",
23
            at = @At(
24
                    value = "INVOKE",
25
                    target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"
26
            )
27
    )
28
    private void nostun$preserveHorizontalSlide(Entity entity, Vec3 velocity) {
29
        if (!EnvironmentMovementController.shouldPreserveHoneySlide(entity)) {
30
            entity.setDeltaMovement(velocity);
31
            return;
32
        }
33
34
        Vec3 current = entity.getDeltaMovement();
35
        entity.setDeltaMovement(new Vec3(current.x, velocity.y, current.z));
36
    }
37
}
38
InputMixinsrc/main/java/combatant/client/mixins/InputMixin.javaJava · 35 lines · 1.2 KB
@Mixin(ClientInput.class)
ModifiesClientInput
InputMixin.javaJava · 35 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.player.ClientInput;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Inject;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15
import combatant.client.features.module.Modules;
16
import combatant.client.features.module.modules.movement.Sprint;
17
18
@Mixin(ClientInput.class)
19
public abstract class InputMixin {
20
21
    @Inject(method = "hasForwardImpulse", at = @At("HEAD"), cancellable = true)
22
    private void allowAllDirections(CallbackInfoReturnable<Boolean> cir) {
23
        Sprint module = Modules.get(Sprint.class);
24
        if (module == null || !module.shouldAllowDirectionalSprint()) return;
25
26
        ClientInput input = (ClientInput) (Object) this;
27
        if (input.keyPresses.forward()
28
                || input.keyPresses.backward()
29
                || input.keyPresses.left()
30
                || input.keyPresses.right()) {
31
            cir.setReturnValue(true);
32
        }
33
    }
34
}
35
ItemCooldownsMixinsrc/main/java/combatant/client/mixins/ItemCooldownsMixin.javaJava · 85 lines · 2.7 KB
@Mixin(ItemCooldowns.class)
ItemCooldownsMixin.javaJava · 85 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.resources.Identifier;
11
import net.minecraft.world.item.ItemCooldowns;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Shadow;
15
import org.spongepowered.asm.mixin.Unique;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.combat.TPSSync;
21
import combatant.client.features.module.modules.movement.Timer;
22
import combatant.client.mixins.accessors.ItemCooldownEntryAccessor;
23
24
import java.util.Iterator;
25
import java.util.Map;
26
27
@Mixin(ItemCooldowns.class)
28
public abstract class ItemCooldownsMixin {
29
30
    @Shadow
31
    private int tickCount;
32
    @Shadow
33
    @Final
34
    private Map<Identifier, ?> cooldowns;
35
    @Unique
36
    private float combatant$timerRemainder = 0f;
37
38
    @Shadow
39
    protected abstract void onCooldownEnded(Identifier groupId);
40
41
    @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
42
    private void combatant$timerCompensate(CallbackInfo ci) {
43
        float mult = Timer.getTickTimer();
44
        float serverDelta = 1.0f;
45
        TPSSync tps = Modules.get(TPSSync.class);
46
        if (tps != null && tps.isEnabled()) {
47
            serverDelta = tps.getServerTickDelta();
48
        }
49
50
        float scale = (mult <= 0.0001f) ? 1.0f : (serverDelta / mult);
51
        if (scale > 1.0f) scale = 1.0f;
52
        if (scale < 0.0f) scale = 0.0f;
53
54
        if (Math.abs(scale - 1.0f) < 0.0001f) {
55
            return;
56
        }
57
58
        float step = scale;
59
        combatant$timerRemainder += step;
60
        int inc = (int) combatant$timerRemainder;
61
        if (inc <= 0) {
62
            ci.cancel();
63
            return;
64
        }
65
        combatant$timerRemainder -= inc;
66
67
        tickCount += inc;
68
        if (!cooldowns.isEmpty()) {
69
            @SuppressWarnings("unchecked")
70
            Iterator<Map.Entry<Identifier, Object>> iterator =
71
                    ((Map<Identifier, Object>) cooldowns).entrySet().iterator();
72
            while (iterator.hasNext()) {
73
                Map.Entry<Identifier, Object> entry = iterator.next();
74
                Object value = entry.getValue();
75
                if (value instanceof ItemCooldownEntryAccessor accessor && accessor.getEndTick() <= tickCount) {
76
                    iterator.remove();
77
                    onCooldownEnded(entry.getKey());
78
                }
79
            }
80
        }
81
82
        ci.cancel();
83
    }
84
}
85
ItemEntityRenderStateMixinsrc/main/java/combatant/client/mixins/ItemEntityRenderStateMixin.javaJava · 30 lines · 800 B
@Mixin(ItemEntityRenderState.class)
ItemEntityRenderStateMixin.javaJava · 30 lines · 800 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.entity.state.ItemEntityRenderState;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Unique;
13
import combatant.client.mixininterface.IItemEntityRenderState;
14
15
@Mixin(ItemEntityRenderState.class)
16
public class ItemEntityRenderStateMixin implements IItemEntityRenderState {
17
    @Unique
18
    private boolean combatant$onGround;
19
20
    @Override
21
    public boolean combatant$isOnGround() {
22
        return combatant$onGround;
23
    }
24
25
    @Override
26
    public void combatant$setOnGround(boolean onGround) {
27
        combatant$onGround = onGround;
28
    }
29
}
30
ItemEntityRendererMixinsrc/main/java/combatant/client/mixins/ItemEntityRendererMixin.javaJava · 77 lines · 3.0 KB
@Mixin(ItemEntityRenderer.class)
ItemEntityRendererMixin.javaJava · 77 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import com.mojang.math.Axis;
12
import net.minecraft.client.renderer.SubmitNodeCollector;
13
import net.minecraft.client.renderer.entity.EntityRenderer;
14
import net.minecraft.client.renderer.entity.EntityRendererProvider;
15
import net.minecraft.client.renderer.entity.ItemEntityRenderer;
16
import net.minecraft.client.renderer.entity.state.ItemEntityRenderState;
17
import net.minecraft.client.renderer.state.level.CameraRenderState;
18
import net.minecraft.util.RandomSource;
19
import net.minecraft.world.entity.item.ItemEntity;
20
import net.minecraft.world.phys.AABB;
21
import org.spongepowered.asm.mixin.Final;
22
import org.spongepowered.asm.mixin.Mixin;
23
import org.spongepowered.asm.mixin.Shadow;
24
import org.spongepowered.asm.mixin.injection.At;
25
import org.spongepowered.asm.mixin.injection.Inject;
26
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27
import combatant.client.features.module.Modules;
28
import combatant.client.features.module.modules.visuals.WorldTweaks;
29
import combatant.client.mixininterface.IItemEntityRenderState;
30
31
@Mixin(ItemEntityRenderer.class)
32
public abstract class ItemEntityRendererMixin extends EntityRenderer<ItemEntity, ItemEntityRenderState> {
33
    @Shadow
34
    @Final
35
    private RandomSource random;
36
37
    protected ItemEntityRendererMixin(EntityRendererProvider.Context ctx) {
38
        super(ctx);
39
    }
40
41
    @Inject(method = "extractRenderState", at = @At("TAIL"))
42
    private void combatant$captureOnGround(ItemEntity itemEntity, ItemEntityRenderState state, float tickDelta, CallbackInfo ci) {
43
        ((IItemEntityRenderState) state).combatant$setOnGround(itemEntity.onGround());
44
    }
45
46
    @Inject(method = "submit", at = @At("HEAD"), cancellable = true)
47
    private void combatant$renderItemPhysics(
48
            ItemEntityRenderState state,
49
            PoseStack matrices,
50
            SubmitNodeCollector queue,
51
            CameraRenderState cameraState,
52
            CallbackInfo ci
53
    ) {
54
        WorldTweaks module = Modules.get(WorldTweaks.class);
55
        if (module == null || !module.isItemPhysicsEnabled() || state.item.isEmpty()) {
56
            return;
57
        }
58
59
        matrices.pushPose();
60
        AABB box = state.item.getModelBoundingBox();
61
        float baseY = -((float) box.minY) + 0.0625F;
62
        matrices.translate(0.0F, baseY, 0.0F);
63
64
        if (((IItemEntityRenderState) state).combatant$isOnGround()) {
65
            matrices.mulPose(Axis.XP.rotationDegrees(90.0F));
66
        } else {
67
            float rotation = ItemEntity.getSpin(state.ageInTicks, state.bobOffset);
68
            matrices.mulPose(Axis.XP.rotationDegrees(rotation * 300.0F));
69
        }
70
71
        ItemEntityRenderer.submitMultipleFromCount(matrices, queue, state.lightCoords, state, this.random, box);
72
        matrices.popPose();
73
        super.submit(state, matrices, queue, cameraState);
74
        ci.cancel();
75
    }
76
}
77
ItemFeatureRendererMixinsrc/main/java/combatant/client/mixins/ItemFeatureRendererMixin.javaJava · 118 lines · 5.7 KB
@Mixin(ItemFeatureRenderer.class)
ItemFeatureRendererMixin.javaJava · 118 lines · 5.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
12
import com.llamalad7.mixinextras.sugar.Local;
13
import com.mojang.blaze3d.vertex.PoseStack;
14
import combatant.client.features.hmi_recode.render.HmiModelQuadList;
15
import net.minecraft.client.renderer.feature.ItemFeatureRenderer;
16
import net.minecraft.client.renderer.rendertype.RenderType;
17
import net.minecraft.client.resources.model.geometry.BakedQuad;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Unique;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.ModifyArg;
22
23
@Mixin(ItemFeatureRenderer.class)
24
public abstract class ItemFeatureRendererMixin {
25
    @Unique
26
    private static final int COMBATANT_VIEW_FADE_DITHER_MARK = 0x00010001;
27
    @Unique
28
    private static final int COMBATANT_VIEW_FADE_A2C_MARK = 0x00010100;
29
30
    @Unique
31
    private static boolean combatant$isViewFadeMarked(int argb) {
32
        int alpha = (argb >>> 24) & 0xFF;
33
        if (alpha >= 255) {
34
            return false;
35
        }
36
        int rgbMarker = argb & 0x00010101;
37
        return rgbMarker == COMBATANT_VIEW_FADE_DITHER_MARK || rgbMarker == COMBATANT_VIEW_FADE_A2C_MARK;
38
    }
39
40
    @Unique
41
    private static boolean combatant$hasViewFadeTint(int[] tints) {
42
        return tints != null && tints.length > 0 && combatant$isViewFadeMarked(tints[0]);
43
    }
44
45
    @ModifyReturnValue(
46
            method = "getLayerColorSafe([ILnet/minecraft/client/resources/model/geometry/BakedQuad$MaterialInfo;)I",
47
            at = @At("RETURN")
48
    )
49
    private static int combatant$applyViewFadeToUntintedItemQuads(int original,
50
                                                                  int[] tints,
51
                                                                  BakedQuad.MaterialInfo materialInfo) {
52
        if (original != -1 || !combatant$hasViewFadeTint(tints)) {
53
            return original;
54
        }
55
        return tints[0];
56
    }
57
58
    @ModifyExpressionValue(
59
            method = "prepareMainSubmit",
60
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/geometry/BakedQuad$MaterialInfo;itemRenderType()Lnet/minecraft/client/renderer/rendertype/RenderType;")
61
    )
62
    private RenderType combatant$useTranslucentRenderTypeForViewFadeItem(RenderType original,
63
                                                                         @Local(argsOnly = true) ItemFeatureRenderer.Submit submit,
64
                                                                         @Local(ordinal = 0) BakedQuad.MaterialInfo materialInfo) {
65
        // Vanilla item translucent sheets render into ITEM_ENTITY_TARGET. For entity fade this can
66
        // corrupt the following world translucent composite, so item layers keep their own type.
67
        return original;
68
    }
69
    @ModifyExpressionValue(
70
            method = "prepareMainSubmit",
71
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer$Submit;pose()Lcom/mojang/blaze3d/vertex/PoseStack$Pose;")
72
    )
73
    private PoseStack.Pose combatant$applyHmiModelPoseMain(PoseStack.Pose original,
74
                                                            @Local(argsOnly = true) ItemFeatureRenderer.Submit submit,
75
                                                            @Local BakedQuad quad) {
76
        return HmiModelQuadList.transform(submit.quads(), original, quad);
77
    }
78
79
    @ModifyExpressionValue(
80
            method = "prepareOutlineSubmit",
81
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer$Submit;pose()Lcom/mojang/blaze3d/vertex/PoseStack$Pose;")
82
    )
83
    private PoseStack.Pose combatant$applyHmiModelPoseOutline(PoseStack.Pose original,
84
                                                               @Local(argsOnly = true) ItemFeatureRenderer.Submit submit,
85
                                                               @Local BakedQuad quad) {
86
        return HmiModelQuadList.transform(submit.quads(), original, quad);
87
    }
88
89
    @ModifyExpressionValue(
90
            method = "prepareFoilSubmit",
91
            at = @At(
92
                    value = "INVOKE",
93
                    target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer$Submit;pose()Lcom/mojang/blaze3d/vertex/PoseStack$Pose;",
94
                    ordinal = 1
95
            )
96
    )
97
    private PoseStack.Pose combatant$applyHmiModelPoseFoil(PoseStack.Pose original,
98
                                                            @Local(argsOnly = true) ItemFeatureRenderer.Submit submit,
99
                                                            @Local BakedQuad quad) {
100
        return HmiModelQuadList.transform(submit.quads(), original, quad);
101
    }
102
103
    @ModifyArg(
104
            method = "prepareFoilSubmit",
105
            at = @At(
106
                    value = "INVOKE",
107
                    target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer;getFoilBuffer(Lnet/minecraft/client/renderer/rendertype/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack$Pose;)Lcom/mojang/blaze3d/vertex/VertexConsumer;"
108
            ),
109
            index = 1
110
    )
111
    private PoseStack.Pose combatant$applyHmiModelPoseFoilDecal(PoseStack.Pose original,
112
                                                                 @Local(argsOnly = true) ItemFeatureRenderer.Submit submit,
113
                                                                 @Local BakedQuad quad) {
114
        return HmiModelQuadList.transform(submit.quads(), original, quad);
115
    }
116
117
}
118
ItemFrameRendererMixinsrc/main/java/combatant/client/mixins/ItemFrameRendererMixin.javaJava · 60 lines · 2.6 KB
@Mixin(value = ItemFrameRenderer.class, priority = 1200)priority 1200
ItemFrameRendererMixin.javaJava · 60 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import combatant.client.features.module.Modules;
12
import combatant.client.features.module.modules.visuals.NoRender;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
15
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
16
import net.minecraft.client.renderer.state.level.CameraRenderState;
17
import net.minecraft.world.entity.decoration.ItemFrame;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.injection.At;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
23
24
@Mixin(value = ItemFrameRenderer.class, priority = 1200)
25
public abstract class ItemFrameRendererMixin {
26
    @Inject(
27
            method = "submit(Lnet/minecraft/client/renderer/entity/state/ItemFrameRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
28
            at = @At(
29
                    value = "INVOKE",
30
                    target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;submit(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
31
                    shift = At.Shift.AFTER
32
            ),
33
            cancellable = true
34
    )
35
    private void combatant$noRenderItemFrame(
36
            ItemFrameRenderState state,
37
            PoseStack poseStack,
38
            SubmitNodeCollector collector,
39
            CameraRenderState cameraState,
40
            CallbackInfo ci
41
    ) {
42
        NoRender noRender = Modules.get(NoRender.class);
43
        if (noRender != null && noRender.offEntity("item_frames")) {
44
            ci.cancel();
45
        }
46
    }
47
48
    @Inject(
49
            method = "shouldShowName(Lnet/minecraft/world/entity/decoration/ItemFrame;D)Z",
50
            at = @At("HEAD"),
51
            cancellable = true
52
    )
53
    private void combatant$noRenderItemFrameName(ItemFrame frame, double distanceSq, CallbackInfoReturnable<Boolean> cir) {
54
        NoRender noRender = Modules.get(NoRender.class);
55
        if (noRender != null && noRender.offEntity("item_frame_name_tags")) {
56
            cir.setReturnValue(false);
57
        }
58
    }
59
}
60
ItemInHandLayerMixinsrc/main/java/combatant/client/mixins/ItemInHandLayerMixin.javaJava · 86 lines · 4.0 KB
@Mixin(ItemInHandLayer.class)
ItemInHandLayerMixin.javaJava · 86 lines · 4.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.vertex.PoseStack;
13
import combatant.client.features.playeranimator.PlayerRigInstance;
14
import combatant.client.features.playeranimator.PlayerRigRenderContext;
15
import combatant.client.features.playeranimator.PlayerRigSocket;
16
import net.minecraft.client.model.ArmedModel;
17
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
18
import net.minecraft.client.renderer.entity.state.EntityRenderState;
19
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
20
import net.minecraft.world.entity.HumanoidArm;
21
import org.joml.Matrix4f;
22
import org.joml.Matrix4fc;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.injection.At;
25
26
/** Routes held items through solved anatomical hand sockets without double-applying vanilla grip offsets. */
27
@Mixin(ItemInHandLayer.class)
28
public abstract class ItemInHandLayerMixin {
29
    private static final float MODEL_UNIT = 1f / 16f;
30
    private static final Matrix4fc RIGHT_ADULT_POST_INVERSE = inverseVanillaPost(HumanoidArm.RIGHT, false);
31
    private static final Matrix4fc LEFT_ADULT_POST_INVERSE = inverseVanillaPost(HumanoidArm.LEFT, false);
32
    private static final Matrix4fc RIGHT_BABY_POST_INVERSE = inverseVanillaPost(HumanoidArm.RIGHT, true);
33
    private static final Matrix4fc LEFT_BABY_POST_INVERSE = inverseVanillaPost(HumanoidArm.LEFT, true);
34
    private static final ThreadLocal<Matrix4f> SOCKET_MATRIX = ThreadLocal.withInitial(Matrix4f::new);
35
36
    @WrapOperation(
37
            method = "submitArmWithItem",
38
            at = @At(
39
                    value = "INVOKE",
40
                    target = "Lnet/minecraft/client/model/ArmedModel;translateToHand(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lnet/minecraft/world/entity/HumanoidArm;Lcom/mojang/blaze3d/vertex/PoseStack;)V"
41
            )
42
    )
43
    private void combatant$translateItemToRig(
44
            ArmedModel model,
45
            EntityRenderState state,
46
            HumanoidArm arm,
47
            PoseStack matrices,
48
            Operation<Void> original
49
    ) {
50
        PlayerRigInstance rig = PlayerRigRenderContext.current();
51
        if (rig == null) {
52
            original.call(model, state, arm, matrices);
53
            return;
54
        }
55
56
        PlayerRigSocket socket = arm == HumanoidArm.LEFT
57
                ? PlayerRigSocket.LEFT_ITEM
58
                : PlayerRigSocket.RIGHT_ITEM;
59
60
        // submitArmWithItem() applies -90X, +180Y and a grip translation immediately after
61
        // translateToHand(). The rig socket already represents the final vanilla-compatible grip,
62
        // so pre-cancel that fixed post transform here. Vanilla then reapplies it and the resulting
63
        // matrix is exactly the solved socket matrix instead of socket * gripOffset.
64
        Matrix4f socketMatrix = SOCKET_MATRIX.get();
65
        rig.socketMatrix(socket, socketMatrix);
66
        matrices.mulPose(socketMatrix);
67
        matrices.mulPose(vanillaPostInverse(arm, state instanceof LivingEntityRenderState living && living.isBaby));
68
    }
69
70
    private static Matrix4fc vanillaPostInverse(HumanoidArm arm, boolean baby) {
71
        if (baby) return arm == HumanoidArm.LEFT ? LEFT_BABY_POST_INVERSE : RIGHT_BABY_POST_INVERSE;
72
        return arm == HumanoidArm.LEFT ? LEFT_ADULT_POST_INVERSE : RIGHT_ADULT_POST_INVERSE;
73
    }
74
75
    private static Matrix4f inverseVanillaPost(HumanoidArm arm, boolean baby) {
76
        float x = baby ? 0f : (arm == HumanoidArm.LEFT ? -1f : 1f) * MODEL_UNIT;
77
        float y = (baby ? 1f : 2f) * MODEL_UNIT;
78
        float z = (baby ? -4.5f : -10f) * MODEL_UNIT;
79
        return new Matrix4f()
80
                .rotateX(-((float) Math.PI * 0.5f))
81
                .rotateY((float) Math.PI)
82
                .translate(x, y, z)
83
                .invert();
84
    }
85
}
86
ItemInHandRendererMixinsrc/main/java/combatant/client/mixins/ItemInHandRendererMixin.javaJava · 323 lines · 12.7 KB
@Mixin(value = ItemInHandRenderer.class, priority = 1100)priority 1100
ModifiesItemInHandRenderer not in 26.3
ItemInHandRendererMixin.javaJava · 323 lines · 12.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import net.fabricmc.api.EnvType;
12
import net.fabricmc.api.Environment;
13
import net.minecraft.client.Minecraft;
14
import net.minecraft.client.player.AbstractClientPlayer;
15
import net.minecraft.client.renderer.ItemInHandRenderer;
16
import net.minecraft.client.renderer.SubmitNodeCollector;
17
import net.minecraft.core.component.DataComponents;
18
import net.minecraft.world.InteractionHand;
19
import net.minecraft.world.entity.HumanoidArm;
20
import net.minecraft.world.entity.LivingEntity;
21
import net.minecraft.world.item.ItemDisplayContext;
22
import net.minecraft.world.item.ItemStack;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Shadow;
25
import org.spongepowered.asm.mixin.Unique;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.ModifyVariable;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30
import combatant.client.features.hmi_recode.HoldMyItems;
31
import combatant.client.features.module.Modules;
32
import combatant.client.features.module.modules.visuals.ViewModel;
33
import combatant.client.render.iris.IrisRuntime;
34
35
@Environment(EnvType.CLIENT)
36
@Mixin(value = ItemInHandRenderer.class, priority = 1100)
37
public abstract class ItemInHandRendererMixin {
38
39
    @Shadow
40
    private void renderPlayerArm(
41
            PoseStack matrices,
42
            SubmitNodeCollector queue,
43
            int light,
44
            float equipProgress,
45
            float swingProgress,
46
            HumanoidArm arm
47
    ) {
48
        throw new AssertionError();
49
    }
50
51
    @Shadow
52
    public abstract void renderItem(
53
            LivingEntity entity,
54
            ItemStack stack,
55
            ItemDisplayContext context,
56
            PoseStack matrices,
57
            SubmitNodeCollector queue,
58
            int light
59
    );
60
61
    @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
62
    private void combatant$skipTickWithoutPlayer(CallbackInfo ci) {
63
        Minecraft mc = Minecraft.getInstance();
64
        if (mc.level != null && mc.player == null) {
65
            ci.cancel();
66
        }
67
    }
68
69
    @Inject(
70
            method = "submitArmWithItem",
71
            at = @At("HEAD"),
72
            cancellable = true
73
    )
74
    private void combatant$applyOffsets(
75
            AbstractClientPlayer player,
76
            float tickDelta,
77
            float pitch,
78
            InteractionHand hand,
79
            float swingProgress,
80
            ItemStack item,
81
            float equipProgress,
82
            PoseStack matrices,
83
            SubmitNodeCollector queue,
84
            int light,
85
            CallbackInfo ci
86
    ) {
87
        ViewModel viewModel = Modules.get(ViewModel.class);
88
        if (viewModel == null || !viewModel.isActiveForHandRender()) return;
89
90
        viewModel.syncHmiBackendForRender();
91
        if (viewModel.isHmiModeActive()) {
92
            // Maps have a dedicated vanilla two-hand/one-hand pipeline. Keep that specialized path
93
            // intact; ordinary held items use the HMI scene below so vanilla item/use/swing
94
            // transforms cannot be stacked a second time on top of the scripted HMI pose.
95
            if (item.has(DataComponents.MAP_ID)) return;
96
97
            // Vanilla also suppresses first-person hands while scoping. Since this branch replaces
98
            // submitArmWithItem for HMI, cancellation is required here as well.
99
            if (player.isScoping()) {
100
                ci.cancel();
101
                return;
102
            }
103
104
            HumanoidArm arm = hand == InteractionHand.MAIN_HAND
105
                    ? player.getMainArm()
106
                    : player.getMainArm().getOpposite();
107
            ItemDisplayContext displayContext = arm == HumanoidArm.RIGHT
108
                    ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND
109
                    : ItemDisplayContext.FIRST_PERSON_LEFT_HAND;
110
111
            // HMI cancels submitArmWithItem and therefore must preserve Iris' own solid/translucent
112
            // hand filtering itself. Without this, solid swords/tools are submitted again in
113
            // HAND_TRANSLUCENT, while a translucent held block can drag HMI's opaque gripping arm
114
            // into the translucent phase. Both cases produce broken arm/item depth with packs.
115
            boolean irisHandPass = IrisRuntime.isShaderpackRendererActive();
116
            boolean irisItemTranslucent = irisHandPass && IrisRuntime.isHeldItemTranslucent(item);
117
            boolean irisRenderingSolid = irisHandPass && IrisRuntime.isHandRenderingSolid();
118
            boolean irisSplitHeldItem = irisHandPass
119
                    && !item.isEmpty()
120
                    && irisItemTranslucent
121
                    && IrisRuntime.hasAnySolidHand();
122
123
            // Normal Iris rule: cancel this item when phase == translucency. HMI only overrides that
124
            // rule for a translucent held item in the solid phase, where it needs to submit the
125
            // gripping arm alone and cache the item pose for the later translucent phase.
126
            if (irisHandPass && !irisSplitHeldItem && irisRenderingSolid == irisItemTranslucent) {
127
                ci.cancel();
128
                return;
129
            }
130
131
            boolean irisSolidArmOnly = irisSplitHeldItem && irisRenderingSolid;
132
            boolean irisTranslucentItemOnly = irisSplitHeldItem && !irisRenderingSolid;
133
            boolean hmiReplay = irisTranslucentItemOnly && viewModel.beginHmiReplayPass();
134
            boolean renderEmptyHand = item.isEmpty()
135
                    && hand == InteractionHand.MAIN_HAND
136
                    && !player.isInvisible();
137
            boolean renderHoldingHand = !item.isEmpty()
138
                    && !irisTranslucentItemOnly
139
                    && viewModel.shouldRenderHmiHoldingHands()
140
                    && !player.isInvisible();
141
142
            matrices.pushPose();
143
            try {
144
                // Keep the user base translation outside the scripted HMI transform stack.
145
                // This makes X/Y/Z stable camera-space offsets, matching Basic ViewModel behavior
146
                // instead of rotating the offset axes with item-specific scripted poses.
147
                viewModel.applyHmiBaseOffset(matrices);
148
149
                HoldMyItems.beginHandRender(
150
                        player,
151
                        tickDelta,
152
                        hand,
153
                        swingProgress,
154
                        item,
155
                        equipProgress,
156
                        matrices,
157
                        viewModel.hmiMotionSettings(),
158
                        renderEmptyHand || renderHoldingHand,
159
                        !item.isEmpty()
160
                );
161
162
                if (item.isEmpty()) {
163
                    // Match vanilla visibility semantics for the empty main hand, but let the HMI
164
                    // hand scripts own its pose.
165
                    if (renderEmptyHand) {
166
                        matrices.pushPose();
167
                        try {
168
                            renderPlayerArm(matrices, queue, light, 0.0f, 0.0f, arm);
169
                        } finally {
170
                            matrices.popPose();
171
                        }
172
                    }
173
                } else {
174
                    if (renderHoldingHand) {
175
                        matrices.pushPose();
176
                        try {
177
                            renderPlayerArm(matrices, queue, light, 0.0f, 0.0f, arm);
178
                        } finally {
179
                            matrices.popPose();
180
                        }
181
                    }
182
183
                    if (irisSolidArmOnly) {
184
                        // The item itself belongs to Iris' translucent hand phase. Evaluate its HMI
185
                        // pose/model commands once now so the later phase can replay exactly the
186
                        // same state without advancing JS springs/events a second time.
187
                        HoldMyItems.applyItemPose(item, new PoseStack());
188
                    } else {
189
                        matrices.pushPose();
190
                        try {
191
                            // renderItem remains the vanilla 26.2 model submission path. The HMI
192
                            // item pose + MiniItems layer is injected immediately before
193
                            // ItemStackRenderState submission below, inside the active HMI scope.
194
                            renderItem(player, item, displayContext, matrices, queue, light);
195
                        } finally {
196
                            matrices.popPose();
197
                        }
198
                    }
199
                }
200
            } finally {
201
                HoldMyItems.endHandRender();
202
                matrices.popPose();
203
                if (hmiReplay) {
204
                    viewModel.endHmiReplayPass();
205
                }
206
            }
207
208
            ci.cancel();
209
            return;
210
        }
211
        if (!viewModel.isBasicModeActive()) return;
212
213
        matrices.translate(
214
                viewModel.swingX.get(),
215
                viewModel.swingY.get(),
216
                viewModel.swingZ.get() + (isInLiquid(player) ? viewModel.liquidOffsetZ.get() : 0.0f)
217
        );
218
    }
219
220
    @Inject(method = "renderPlayerArm", at = @At("HEAD"))
221
    private void combatant$applyHmiHandRelative(
222
            PoseStack matrices,
223
            SubmitNodeCollector queue,
224
            int light,
225
            float equipProgress,
226
            float swingProgress,
227
            HumanoidArm arm,
228
            CallbackInfo ci
229
    ) {
230
        ViewModel viewModel = Modules.get(ViewModel.class);
231
        if (viewModel == null || !viewModel.isHmiModeActive()) return;
232
        HoldMyItems.applyHandRelative(matrices);
233
    }
234
235
    @ModifyVariable(
236
            method = "submitArmWithItem",
237
            at = @At("HEAD"),
238
            argsOnly = true,
239
            index = 7)
240
    private float combatant$scaleEquipProgress(float equipProgress) {
241
        ViewModel viewModel = Modules.get(ViewModel.class);
242
        if (viewModel == null || !viewModel.isBasicModeActive()) return equipProgress;
243
        return equipProgress * viewModel.equipLowering.get();
244
    }
245
246
    @Unique
247
    private boolean isInLiquid(AbstractClientPlayer player) {
248
        return player != null && (player.isInWater() || player.isInLava());
249
    }
250
251
    @Inject(
252
            method = "renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V",
253
            at = @At(
254
                    value = "INVOKE",
255
                    target = "Lnet/minecraft/client/renderer/item/ItemStackRenderState;submit(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;III)V"
256
            )
257
    )
258
    private void combatant$scaleMiniItems(
259
            LivingEntity entity,
260
            ItemStack stack,
261
            ItemDisplayContext ctx,
262
            PoseStack ms,
263
            SubmitNodeCollector queue,
264
            int light,
265
            CallbackInfo ci
266
    ) {
267
        ViewModel viewModel = Modules.get(ViewModel.class);
268
        if (viewModel == null || !viewModel.isActiveForHandRender()) return;
269
        if (!ctx.firstPerson()) return;
270
271
        viewModel.syncHmiBackendForRender();
272
        if (viewModel.isHmiModeActive()) {
273
            HoldMyItems.applyItemPose(stack, ms);
274
            // MiniItems is a ViewModel composition layer, not a Basic-only animation.
275
            // Apply it after HMI so resource-pack poses keep their original pivot/translation.
276
            viewModel.applyMini(ms, stack);
277
            return;
278
        }
279
280
        viewModel.applyMini(ms, stack);
281
    }
282
283
    @Inject(
284
            method = "swingArm",
285
            at = @At("HEAD"),
286
            cancellable = true
287
    )
288
    private void combatant$customSwing(
289
            float swingProgress,
290
            PoseStack ms,
291
            int direction,
292
            HumanoidArm arm,
293
            CallbackInfo ci
294
    ) {
295
        ViewModel viewModel = Modules.get(ViewModel.class);
296
        if (viewModel == null || !viewModel.isActiveForHandRender()) return;
297
298
        if (viewModel.isHmiModeActive()) {
299
            // HMI owns swings in JavaScript. This still matters for the dedicated vanilla map path,
300
            // which is intentionally not replaced by the generic HMI held-item renderer above.
301
            ci.cancel();
302
            return;
303
        }
304
305
        if (!viewModel.isBasicModeActive() || viewModel.mc.player == null) return;
306
307
        ItemStack stack = viewModel.mc.player.getMainHandItem();
308
        if (!viewModel.shouldSwing(stack))
309
            return;
310
311
        if (viewModel.shouldBypassRotationTransform(stack))
312
            return;
313
314
        // Cancel vanilla swing entirely
315
        ci.cancel();
316
317
        viewModel.applySwingAnimation(swingProgress, ms, arm);
318
    }
319
}
320
321
322
323
ItemMixinsrc/main/java/combatant/client/mixins/ItemMixin.javaJava · 32 lines · 1013 B
@Mixin(Item.class)
ModifiesItem
ItemMixin.javaJava · 32 lines · 1013 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.world.entity.player.Player;
11
import net.minecraft.world.item.Item;
12
import net.minecraft.world.phys.Vec3;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Redirect;
16
import combatant.client.util.aiming.RotationManager;
17
18
@Mixin(Item.class)
19
public class ItemMixin {
20
21
    @Redirect(
22
            method = "getPlayerPOVHitResult",
23
            at = @At(
24
                    value = "INVOKE",
25
                    target = "Lnet/minecraft/world/entity/player/Player;calculateViewVector(FF)Lnet/minecraft/world/phys/Vec3;"
26
            )
27
    )
28
    private static Vec3 combatant$raycastRotation(Player player, float pitch, float yaw) {
29
        return RotationManager.INSTANCE.getMovementRotation().directionVector();
30
    }
31
}
32
ItemStackMixinsrc/main/java/combatant/client/mixins/ItemStackMixin.javaJava · 112 lines · 4.1 KB
@Mixin(ItemStack.class)
ModifiesItemStack
ItemStackMixin.javaJava · 112 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.network.chat.Component;
11
import net.minecraft.world.entity.player.Player;
12
import net.minecraft.world.item.Item;
13
import net.minecraft.world.item.ItemStack;
14
import net.minecraft.world.item.TooltipFlag;
15
import org.jetbrains.annotations.Nullable;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
21
import combatant.client.features.gui.hud.nondraggable.impl.BetterTooltips;
22
import combatant.client.util.item.IllegalItemUtil;
23
import combatant.client.util.item.RarityColorUtil;
24
import combatant.client.util.item.TopEnchantUtil;
25
26
import java.util.ArrayList;
27
import java.util.HashSet;
28
import java.util.List;
29
import java.util.Set;
30
31
@Mixin(ItemStack.class)
32
public class ItemStackMixin {
33
34
    @Unique
35
    private static Component recolor(Component text, int argb) {
36
        int rgb = argb & 0x00FFFFFF;
37
        return text.copy().setStyle(text.getStyle().withColor(rgb));
38
    }
39
40
    @Unique
41
    private static int argbFrom(float[] rgba) {
42
        if (rgba == null || rgba.length < 3) return 0xFFFFFFFF;
43
        float r = rgba[0], g = rgba[1], b = rgba[2];
44
        float a = rgba.length > 3 ? rgba[3] : 1f;
45
        int ai = (int) (a * 255) & 0xFF;
46
        int ri = (int) (r * 255) & 0xFF;
47
        int gi = (int) (g * 255) & 0xFF;
48
        int bi = (int) (b * 255) & 0xFF;
49
        return (ai << 24) | (ri << 16) | (gi << 8) | bi;
50
    }
51
52
    @Inject(method = "getTooltipLines", at = @At("RETURN"), cancellable = true)
53
    private void combatant$colorizeTooltip(Item.TooltipContext tooltipContext, @Nullable Player player, TooltipFlag type, CallbackInfoReturnable<List<Component>> cir) {
54
        ItemStack self = (ItemStack) (Object) this;
55
        // Item tooltip scheduling often reaches GuiGraphicsExtractor through the generic
56
        // lines+optional-image overload. Capture the producing stack independently from text
57
        // colorization so the central tooltip hook can still select the item renderer.
58
        BetterTooltips.setLastTooltipStack(self);
59
60
        BetterTooltips tooltips = BetterTooltips.get();
61
        if (tooltips == null || !tooltips.isItemInfoColorizeEnabled()) return;
62
63
        List<Component> original = cir.getReturnValue();
64
        if (original == null || original.isEmpty()) return;
65
66
        List<Component> modified = new ArrayList<>(original);
67
68
        int illegalColor = IllegalItemUtil.illegalColor();
69
        int topColor = TopEnchantUtil.topColor();
70
        int rarityColor = argbFrom(RarityColorUtil.INSTANCE.getRarityColor(self));
71
72
        Set<String> illegalLabels = new HashSet<>();
73
        Set<String> topLabels = new HashSet<>();
74
        IllegalItemUtil.collectEnchants(self, (label, overMax) -> {
75
            if (overMax) illegalLabels.add(label.trim());
76
        });
77
        TopEnchantUtil.collectTopEnchants(self, (label, isTop) -> {
78
            if (isTop) topLabels.add(label.trim());
79
        });
80
81
        boolean hasIllegal = !illegalLabels.isEmpty();
82
        boolean hasTop = !topLabels.isEmpty();
83
84
        if (!modified.isEmpty()) {
85
            int nameColor = hasIllegal ? illegalColor : (hasTop ? topColor : rarityColor);
86
            modified.set(0, recolor(modified.get(0), nameColor));
87
        }
88
89
        for (int i = 1; i < modified.size(); i++) {
90
            Component t = modified.get(i);
91
            String trimmed = t.getString().trim();
92
            if (illegalLabels.contains(trimmed)) {
93
                modified.set(i, recolor(t, illegalColor));
94
                continue;
95
            }
96
            if (topLabels.contains(trimmed)) {
97
                modified.set(i, recolor(t, topColor));
98
                continue;
99
            }
100
            if (hasIllegal && t.getStyle().getColor() == null) {
101
                modified.set(i, recolor(t, illegalColor));
102
            }
103
        }
104
105
        cir.setReturnValue(modified);
106
    }
107
}
108
109
110
111
112
JumpBarMixinsrc/main/java/combatant/client/mixins/JumpBarMixin.javaJava · 50 lines · 1.8 KB
@Mixin(JumpableVehicleBar.class)
JumpBarMixin.javaJava · 50 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.DeltaTracker;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.contextualbar.JumpableVehicleBar;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
19
import combatant.client.runtime.RuntimeGate;
20
21
@Mixin(JumpableVehicleBar.class)
22
public abstract class JumpBarMixin {
23
24
    @Inject(method = "extractBackground", at = @At("HEAD"), cancellable = true)
25
    private void combatant$renderJumpBar(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
26
        if (!RuntimeGate.canRunHud()) return;
27
        Minecraft mc = Minecraft.getInstance();
28
        if (mc == null || mc.player == null) return;
29
30
        CustomBar bar = CustomBar.get();
31
        if (bar == null) return;
32
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
33
34
        ci.cancel();
35
    }
36
37
    @Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
38
    private void combatant$renderJumpAddons(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
39
        if (!RuntimeGate.canRunHud()) return;
40
        Minecraft mc = Minecraft.getInstance();
41
        if (mc == null || mc.player == null) return;
42
43
        CustomBar bar = CustomBar.get();
44
        if (bar == null) return;
45
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
46
47
        ci.cancel();
48
    }
49
}
50
KeyMappingMixinsrc/main/java/combatant/client/mixins/KeyMappingMixin.javaJava · 36 lines · 1.1 KB
@Mixin(KeyMapping.class)
ModifiesKeyMapping
KeyMappingMixin.javaJava · 36 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.KeyMapping;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Shadow;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
16
import combatant.client.events.Events;
17
import combatant.client.events.impl.KeybindIsPressedEvent;
18
19
@Mixin(KeyMapping.class)
20
public class KeyMappingMixin {
21
22
    @Shadow
23
    private boolean isDown;
24
25
    @Inject(method = "isDown", at = @At("HEAD"), cancellable = true)
26
    private void combatant$keybindIsPressedEvent(CallbackInfoReturnable<Boolean> cir) {
27
        if (!Events.BUS.hasListeners(KeybindIsPressedEvent.class)) {
28
            return;
29
        }
30
31
        KeybindIsPressedEvent event = new KeybindIsPressedEvent((KeyMapping) (Object) this, isDown);
32
        Events.BUS.post(event);
33
        cir.setReturnValue(event.isPressed());
34
    }
35
}
36
KeyboardInputMixinsrc/main/java/combatant/client/mixins/KeyboardInputMixin.javaJava · 48 lines · 1.6 KB
@Mixin(KeyboardInput.class)
KeyboardInputMixin.javaJava · 48 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.player.KeyboardInput;
13
import net.minecraft.world.entity.player.Input;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import combatant.client.util.aiming.RotationManager;
17
import combatant.client.util.aiming.RotationUtil;
18
import combatant.client.util.aiming.data.Rotation;
19
import combatant.client.util.aiming.features.MovementCorrection;
20
21
@Mixin(KeyboardInput.class)
22
public abstract class KeyboardInputMixin extends InputMixin {
23
24
    @ModifyExpressionValue(
25
            method = "tick",
26
            at = @At(
27
                    value = "NEW",
28
                    target = "(ZZZZZZZ)Lnet/minecraft/world/entity/player/Input;"
29
            )
30
    )
31
    private Input combatant$applyFreeCorrection(Input original) {
32
        Minecraft mc = Minecraft.getInstance();
33
        if (mc.player == null) {
34
            return original;
35
        }
36
37
        var target = RotationManager.INSTANCE.getActiveRotationTarget();
38
        if (target == null
39
                || target.movementCorrection != MovementCorrection.SILENT
40
                || !target.freeCorrection) {
41
            return original;
42
        }
43
44
        Rotation rotation = RotationManager.INSTANCE.getMovementRotation();
45
        return RotationUtil.correctMovementInput(original, mc.player.getYRot(), rotation.yaw());
46
    }
47
}
48
KeyboardMixinsrc/main/java/combatant/client/mixins/KeyboardMixin.javaJava · 297 lines · 11.7 KB
@Mixin(KeyboardHandler.class)
KeyboardMixin.javaJava · 297 lines · 11.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.platform.InputConstants;
11
import combatant.client.features.gui.clickgui.*;
12
import combatant.client.features.gui.preview.VisualPreviewScreen;
13
import combatant.client.util.screen.ClientScreen;
14
import net.minecraft.client.KeyMapping;
15
import net.minecraft.client.KeyboardHandler;
16
import net.minecraft.client.Minecraft;
17
import net.minecraft.client.Options;
18
import net.minecraft.client.gui.components.EditBox;
19
import net.minecraft.client.gui.screens.ChatScreen;
20
import net.minecraft.client.gui.screens.Screen;
21
import net.minecraft.client.input.CharacterEvent;
22
import net.minecraft.client.input.KeyEvent;
23
import org.lwjgl.glfw.GLFW;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Unique;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import combatant.client.events.Events;
30
import combatant.client.events.impl.KeyInputEvent;
31
import combatant.client.features.gui.chat.BetterChatRenderer;
32
import combatant.client.features.gui.chat.BetterChatSearch;
33
import combatant.client.features.gui.chat.BetterChatStoreManager;
34
import combatant.client.features.gui.clickgui.*;
35
import combatant.client.features.gui.hud.draggable.impl.BetterChat;
36
import combatant.client.features.module.ModuleManager;
37
import combatant.client.mixins.accessors.ChatScreenAccessor;
38
import combatant.client.runtime.RuntimeGate;
39
import combatant.client.util.NarratorBlocker;
40
import combatant.client.util.input.KeyManager;
41
import combatant.client.util.text.ClipboardUtil;
42
43
@Mixin(KeyboardHandler.class)
44
public class KeyboardMixin {
45
46
47
    @Unique
48
    private static void forwardMovementKeys(Options options, KeyEvent input, boolean pressed) {
49
        if (options.keyUp.matches(input)
50
                || options.keyDown.matches(input)
51
                || options.keyLeft.matches(input)
52
                || options.keyRight.matches(input)
53
                || options.keyJump.matches(input)
54
                || options.keyShift.matches(input)
55
                || options.keySprint.matches(input)) {
56
            InputConstants.Key key = InputConstants.getKey(input);
57
            KeyMapping.set(key, pressed);
58
        }
59
    }
60
61
    @Unique
62
    private static void releaseMovementKeys(Options options) {
63
        options.keyUp.setDown(false);
64
        options.keyDown.setDown(false);
65
        options.keyLeft.setDown(false);
66
        options.keyRight.setDown(false);
67
        options.keyJump.setDown(false);
68
        options.keyShift.setDown(false);
69
        options.keySprint.setDown(false);
70
    }
71
72
    // ===== CHAR TYPING =====
73
    @Inject(method = "charTyped", at = @At("HEAD"), cancellable = true)
74
    private void combatant$onChar(long window, CharacterEvent input, CallbackInfo ci) {
75
        Minecraft mc = Minecraft.getInstance();
76
        if (RuntimeGate.canRunHud()
77
                && ClientScreen.current() instanceof ChatScreen
78
                && BetterChat.isActive()) {
79
            BetterChat betterChat = BetterChat.get();
80
            if (betterChat != null && betterChat.isPasswordRevealBindHeld()) {
81
                ci.cancel();
82
                return;
83
            }
84
        }
85
        if (RuntimeGate.canRunHud()
86
                && ClientScreen.current() instanceof ChatScreen
87
                && BetterChat.isActive()
88
                && BetterChatSearch.isActive()) {
89
            BetterChatSearch.append((char) input.codepoint());
90
            ci.cancel();
91
            return;
92
        }
93
        // VisualPreviewScreen owns its text fields. The enabled ClickGui module must not route
94
        // characters into the hidden ClickGui section while this separate screen is active.
95
        if (ClientScreen.current() instanceof VisualPreviewScreen) return;
96
        if (!RuntimeGate.canRunClientLogic() || !ModuleManager.isEnabled("clickgui")) return;
97
        Screen activeScreen = ClientScreen.current();
98
        if (!(activeScreen instanceof ClickGuiScreen
99
                || activeScreen instanceof ClickGuiPickerScreen
100
                || activeScreen instanceof ClickGuiEditorScreen
101
                || activeScreen instanceof VisualPreviewScreen)) return;
102
103
        char c = (char) input.codepoint();
104
105
        if (ClickGuiSearch.isActive()) {
106
            ClickGuiRenderer.onCharTyped(c);
107
            ci.cancel();
108
            return;
109
        }
110
111
        if (ClickGuiRenderer.onCharTyped(c)) {
112
            ci.cancel();
113
        }
114
    }
115
116
    // ===== KEY DOWN =====
117
    @Inject(method = "keyPress", at = @At("HEAD"), cancellable = true)
118
    private void combatant$onKey(long window, int action, KeyEvent input, CallbackInfo ci) {
119
        KeyManager.handleKeyEvent(input.key(), input.scancode(), action);
120
121
        // Preserve low-level key state above, then leave the event entirely to the active preview
122
        // Screen. In particular, do this before addon events and the global ClickGui Esc handler.
123
        if (ClientScreen.current() instanceof VisualPreviewScreen) return;
124
125
        Minecraft mc = Minecraft.getInstance();
126
        KeyInputEvent event = new KeyInputEvent(action, input);
127
        Events.BUS.post(event);
128
        if (event.isCancelled()) {
129
            ci.cancel();
130
            return;
131
        }
132
133
        if (RuntimeGate.canRunHud()
134
                && ClientScreen.current() instanceof ChatScreen
135
                && BetterChat.isActive()) {
136
            BetterChat betterChat = BetterChat.get();
137
            if (betterChat != null && betterChat.consumePasswordRevealToggle()) {
138
                if (action != GLFW.GLFW_RELEASE) {
139
                    BetterChatRenderer.togglePasswordRevealFromBind();
140
                    ci.cancel();
141
                    return;
142
                }
143
            }
144
        }
145
146
        Screen screen = ClientScreen.current();
147
        boolean narratorHotkeyContext = screen == null
148
                || !(screen.getFocused() instanceof EditBox)
149
                || !((EditBox) screen.getFocused()).canConsumeInput();
150
        if (RuntimeGate.canRunClientLogic()
151
                && NarratorBlocker.isBlocked()
152
                && narratorHotkeyContext
153
                && action != GLFW.GLFW_RELEASE
154
                && input.hasControlDownWithQuirk()
155
                && input.key() == GLFW.GLFW_KEY_B) {
156
            NarratorBlocker.enforce(mc);
157
            ci.cancel();
158
            return;
159
        }
160
161
        if (RuntimeGate.canRunClientLogic()
162
                && ModuleManager.isEnabled("clickgui")
163
                && (ClientScreen.current() instanceof ClickGuiScreen
164
                || ClientScreen.current() instanceof ClickGuiPickerScreen
165
                || ClientScreen.current() instanceof ClickGuiEditorScreen)
166
        ) {
167
            if (ClickGuiRenderer.isBlockingModuleKeybinds()) {
168
                releaseMovementKeys(mc.options);
169
            } else {
170
                forwardMovementKeys(mc.options, input, action != GLFW.GLFW_RELEASE);
171
            }
172
        }
173
        if (RuntimeGate.canRunHud()
174
                && ClientScreen.current() instanceof ChatScreen
175
                && BetterChat.isActive()
176
                && BetterChatSearch.isActive()) {
177
            int key = input.key();
178
            if (action == GLFW.GLFW_PRESS || action == GLFW.GLFW_REPEAT) {
179
                boolean ctrlOrCmd = input.hasControlDownWithQuirk();
180
181
                if (ctrlOrCmd && key == GLFW.GLFW_KEY_V) {
182
                    BetterChatSearch.append(ClipboardUtil.get());
183
                    ci.cancel();
184
                    return;
185
                }
186
187
                if (ctrlOrCmd && key == GLFW.GLFW_KEY_A) {
188
                    BetterChatSearch.clearText();
189
                    ci.cancel();
190
                    return;
191
                }
192
193
                if (key == GLFW.GLFW_KEY_BACKSPACE) {
194
                    BetterChatSearch.backspace();
195
                    ci.cancel();
196
                    return;
197
                }
198
199
                if (key == GLFW.GLFW_KEY_ENTER || key == GLFW.GLFW_KEY_KP_ENTER) {
200
                    BetterChatRenderer.resetScroll();
201
                    BetterChatSearch.startSearch(BetterChatStoreManager.getActiveStore(mc));
202
                    BetterChatSearch.setActive(false);
203
                    ci.cancel();
204
                    return;
205
                }
206
207
                if (key == GLFW.GLFW_KEY_ESCAPE) {
208
                    BetterChatSearch.deactivate();
209
                    ci.cancel();
210
                    return;
211
                }
212
            }
213
        }
214
        if (RuntimeGate.canRunHud()
215
                && ClientScreen.current() instanceof ChatScreen
216
                && BetterChat.isActive()
217
                && !BetterChatSearch.isActive()) {
218
            if (action == 1) { // press
219
                int key = input.key();
220
                if (key == 257 || key == 335) { // enter
221
                    EditBox field = ((ChatScreenAccessor) ClientScreen.current()).getChatField();
222
                    BetterChatRenderer.applyAutoPrefixIfNeeded(field);
223
                }
224
            }
225
        }
226
        if (!RuntimeGate.canRunClientLogic() || !ModuleManager.isEnabled("clickgui")) return;
227
        Screen activeScreen = ClientScreen.current();
228
        if (!(activeScreen instanceof ClickGuiScreen
229
                || activeScreen instanceof ClickGuiPickerScreen
230
                || activeScreen instanceof ClickGuiEditorScreen
231
                || activeScreen instanceof VisualPreviewScreen)) return;
232
233
        int key = input.key();
234
        int scancode = input.scancode();
235
        int modifiers = input.modifiers();
236
237
        // ESC — закрыть GUI
238
        if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_PRESS) {
239
            if (ClickGuiRenderer.onKey(GLFW.GLFW_KEY_ESCAPE, scancode, GLFW.GLFW_PRESS, modifiers)) {
240
                ci.cancel();
241
                return;
242
            }
243
            if (ClientScreen.current() instanceof ClickGuiEditorScreen) {
244
                ClickGuiRenderer.closeGuiEditor();
245
                ci.cancel();
246
                return;
247
            }
248
            ModuleManager.setEnabled("clickgui", false);
249
            ci.cancel();
250
            return;
251
        }
252
253
        // РџРѕРёСЃРє РІ GUI
254
        if (ClickGuiSearch.isActive()) {
255
            ClickGuiRenderer.onKey(key, scancode, action, modifiers);
256
            ci.cancel();
257
            return;
258
        }
259
260
        // Обычное событие клавиши
261
        if (ClickGuiRenderer.onKey(key, scancode, action, modifiers)) {
262
            ci.cancel();
263
        }
264
    }
265
266
    @Inject(method = "keyPress", at = @At("HEAD"))
267
    private void combatant$betterChatCopy(long window, int action, KeyEvent input, CallbackInfo ci) {
268
        if (action != 1) return; // GLFW_PRESS
269
        Minecraft mc = Minecraft.getInstance();
270
        if (!(ClientScreen.current() instanceof ChatScreen)) return;
271
        if (!RuntimeGate.canRunHud()) return;
272
        if (!BetterChat.isActive()) return;
273
        if ((input.modifiers() & GLFW.GLFW_MOD_CONTROL) == 0) return;
274
        if (input.key() == GLFW.GLFW_KEY_C) {
275
            BetterChatRenderer.copySelectionToClipboard();
276
        }
277
    }
278
279
    @Inject(method = "keyPress", at = @At("HEAD"))
280
    private void combatant$betterChat$clearOnDebug(long window, int action, KeyEvent input, CallbackInfo ci) {
281
        if (action != GLFW.GLFW_PRESS) return;
282
        if (input.key() != GLFW.GLFW_KEY_D) return;
283
        Minecraft mc = Minecraft.getInstance();
284
        if (mc == null) return;
285
        if (!RuntimeGate.canRunHud()) return;
286
        // F3 + D clears vanilla chat; mirror it for BetterChat
287
        if (InputConstants.isKeyDown(mc.getWindow(), GLFW.GLFW_KEY_F3)) {
288
            BetterChatStoreManager.clearActive();
289
            BetterChatRenderer.resetScroll();
290
        }
291
    }
292
}
293
294
295
296
297
LavaFogModifierMixinsrc/main/java/combatant/client/mixins/LavaFogModifierMixin.javaJava · 52 lines · 1.8 KB
@Mixin(value = LavaFogEnvironment.class, priority = 1200)priority 1200
LavaFogModifierMixin.javaJava · 52 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.multiplayer.ClientLevel;
13
import net.minecraft.client.renderer.fog.FogData;
14
import net.minecraft.client.renderer.fog.environment.LavaFogEnvironment;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.visuals.WorldTweaks;
21
22
@Mixin(value = LavaFogEnvironment.class, priority = 1200)
23
public class LavaFogModifierMixin {
24
25
    @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
26
    private void combatant$noLavaFog(FogData data,
27
                                     Camera camera,
28
                                     ClientLevel world,
29
                                     float viewDistance,
30
                                     DeltaTracker tickCounter,
31
                                     CallbackInfo ci) {
32
        WorldTweaks module = Modules.get(WorldTweaks.class);
33
        if (module == null || !module.isFogControlEnabled()) return;
34
        if (module.isFogModifyEnabled()) {
35
            module.applyFogOverride(data);
36
            ci.cancel();
37
            return;
38
        }
39
        if (!module.disableLavaFog()) return;
40
41
        float far = Math.max(viewDistance, 16.0f);
42
        data.environmentalStart = far;
43
        data.environmentalEnd = far;
44
        data.renderDistanceStart = far;
45
        data.renderDistanceEnd = far;
46
        data.skyEnd = far;
47
        data.cloudEnd = far;
48
        ci.cancel();
49
    }
50
}
51
52
LevelExtractorMixinsrc/main/java/combatant/client/mixins/LevelExtractorMixin.javaJava · 59 lines · 2.1 KB
@Mixin(LevelExtractor.class)
LevelExtractorMixin.javaJava · 59 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.Minecraft;
13
import net.minecraft.client.renderer.culling.Frustum;
14
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
15
import net.minecraft.client.renderer.entity.state.EntityRenderState;
16
import net.minecraft.client.renderer.extract.LevelExtractor;
17
import net.minecraft.client.renderer.state.level.LevelRenderState;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.injection.At;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
import combatant.client.features.module.Modules;
23
import combatant.client.features.module.modules.visuals.Freecam;
24
import combatant.client.mixins.accessors.LevelExtractorAccessor;
25
26
@Mixin(LevelExtractor.class)
27
public abstract class LevelExtractorMixin {
28
29
    @Inject(method = "extractVisibleEntities", at = @At("TAIL"))
30
    private void freecam$addLocalPlayer(
31
            Camera camera,
32
            Frustum frustum,
33
            DeltaTracker tickCounter,
34
            LevelRenderState renderStates,
35
            CallbackInfo ci
36
    ) {
37
        Freecam fc = Modules.get(Freecam.class);
38
        Minecraft mc = Minecraft.getInstance();
39
40
        if (fc == null || !fc.isEnabled()) return;
41
        if (mc.player == null) return;
42
43
        for (EntityRenderState state : renderStates.entityRenderStates) {
44
            if (state instanceof AvatarRenderState prs && prs.id == mc.player.getId()) {
45
                return;
46
            }
47
        }
48
49
        EntityRenderState state = ((LevelExtractorAccessor) this).combatant$invokeExtractEntity(
50
                mc.player,
51
                tickCounter.getGameTimeDeltaPartialTick(false)
52
        );
53
54
        if (state instanceof AvatarRenderState prs) {
55
            renderStates.entityRenderStates.add(prs);
56
        }
57
    }
58
}
59
LevelMixinsrc/main/java/combatant/client/mixins/LevelMixin.javaJava · 44 lines · 1.6 KB
@Mixin(Level.class)
ModifiesLevel
LevelMixin.javaJava · 44 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.world.level.Level;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Inject;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15
import combatant.client.features.module.Modules;
16
import combatant.client.features.module.modules.visuals.WorldTweaks;
17
import combatant.client.features.module.modules.visuals.WorldTweaks.WeatherMode;
18
19
@Mixin(Level.class)
20
public abstract class LevelMixin {
21
22
    @Inject(method = "getRainLevel", at = @At("HEAD"), cancellable = true)
23
    private void picker$rainGradient(float tickDelta, CallbackInfoReturnable<Float> cir) {
24
        WorldTweaks wt = Modules.get(WorldTweaks.class);
25
        if (wt == null || !wt.isWeatherControlEnabled()) return;
26
27
        WeatherMode mode = wt.getWeatherMode();
28
        cir.setReturnValue(
29
                (mode == WeatherMode.RAIN || mode == WeatherMode.THUNDER) ? 1.0F : 0.0F
30
        );
31
    }
32
33
    @Inject(method = "getThunderLevel", at = @At("HEAD"), cancellable = true)
34
    private void picker$thunderGradient(float tickDelta, CallbackInfoReturnable<Float> cir) {
35
        WorldTweaks wt = Modules.get(WorldTweaks.class);
36
        if (wt == null || !wt.isWeatherControlEnabled()) return;
37
38
        cir.setReturnValue(
39
                wt.getWeatherMode() == WeatherMode.THUNDER ? 1.0F : 0.0F
40
        );
41
    }
42
43
}
44
LevelRendererMixinsrc/main/java/combatant/client/mixins/LevelRendererMixin.javaJava · 308 lines · 14.3 KB
@Mixin(LevelRenderer.class)
LevelRendererMixin.javaJava · 308 lines · 14.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
12
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
13
import com.mojang.blaze3d.buffers.GpuBufferSlice;
14
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
15
import com.mojang.blaze3d.framegraph.FramePass;
16
import com.mojang.blaze3d.pipeline.RenderTarget;
17
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
18
import com.mojang.blaze3d.resource.ResourceHandle;
19
import com.mojang.blaze3d.vertex.PoseStack;
20
import net.minecraft.client.CloudStatus;
21
import net.minecraft.client.DeltaTracker;
22
import net.minecraft.client.Minecraft;
23
import net.minecraft.client.renderer.GameRenderer;
24
import net.minecraft.client.renderer.LevelRenderer;
25
import net.minecraft.client.renderer.LevelTargetBundle;
26
import net.minecraft.client.renderer.SubmitNodeCollector;
27
import net.minecraft.client.renderer.state.level.LevelRenderState;
28
import net.minecraft.client.renderer.state.level.SkyRenderState;
29
import net.minecraft.world.level.dimension.DimensionType;
30
import net.minecraft.world.level.material.FogType;
31
import org.spongepowered.asm.mixin.Final;
32
import org.spongepowered.asm.mixin.Mixin;
33
import org.spongepowered.asm.mixin.Shadow;
34
import org.spongepowered.asm.mixin.Unique;
35
import org.spongepowered.asm.mixin.injection.At;
36
import org.spongepowered.asm.mixin.injection.Inject;
37
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
38
import combatant.client.features.module.Modules;
39
import combatant.client.features.module.modules.visuals.BlockHighlight;
40
import combatant.client.features.module.modules.visuals.WorldTweaks;
41
import combatant.client.mixins.accessors.GameRendererAccessor;
42
import combatant.client.mixins.accessors.LevelRendererAccessor;
43
import combatant.client.render.engine.core.CombatantRenderSystem;
44
import combatant.client.render.engine.core.CombatantWorldMatrices;
45
import combatant.client.render.engine.depth.PreTranslucentDepth;
46
import combatant.client.render.engine.depth.WorldSceneDepth;
47
import combatant.client.render.engine.world.environment.CloudProfileRegistry;
48
import combatant.client.render.engine.world.environment.DimensionRenderProfile;
49
import combatant.client.render.engine.world.environment.DimensionRenderProfileRegistry;
50
import combatant.client.render.iris.IrisRuntime;
51
52
@Mixin(LevelRenderer.class)
53
public abstract class LevelRendererMixin {
54
55
56
    @Shadow
57
    @Final
58
    private LevelTargetBundle targets;
59
60
    @WrapOperation(
61
            method = "addSkyPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/state/level/CameraRenderState;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V",
62
            at = @At(
63
                    value = "INVOKE",
64
                    target = "Lnet/minecraft/client/renderer/GameRenderer;mainRenderTarget()Lcom/mojang/blaze3d/pipeline/RenderTarget;"
65
            )
66
    )
67
    private RenderTarget combatant$stableSkyRendererTarget(GameRenderer instance, Operation<RenderTarget> original) {
68
        return ((GameRendererAccessor) instance).combatant$getMainRenderTargetRaw();
69
    }
70
71
    @Unique
72
    private static void combatant$dependsOn(FramePass pass, ResourceHandle<RenderTarget> handle) {
73
        if (pass != null && handle != null) {
74
            pass.reads(handle);
75
        }
76
    }
77
78
    @Unique
79
    @SuppressWarnings("unchecked")
80
    private static ResourceHandle<RenderTarget> combatant$asRenderTargetHandle(ResourceHandle<?> handle) {
81
        return (ResourceHandle<RenderTarget>) handle;
82
    }
83
84
    @Unique
85
    private static RenderTarget combatant$getFramebuffer(ResourceHandle<RenderTarget> handle) {
86
        if (handle == null) {
87
            return null;
88
        }
89
        try {
90
            return handle.get();
91
        } catch (Throwable ignored) {
92
            return null;
93
        }
94
    }
95
96
    @Unique
97
    private static boolean combatant$needsWorldSceneDepthCapture() {
98
        // Retained as a compatibility gate for the existing capture hook. ReimaginedVisual no
99
        // longer uses WorldSceneDepth; deferred camera post consumes FINAL_RESOLVED_DEPTH.
100
        return false;
101
    }
102
103
    @Unique
104
    private static boolean shouldSkipSky(net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState) {
105
        FogType submersion = cameraRenderState.fogType;
106
        if (submersion == FogType.POWDER_SNOW || submersion == FogType.LAVA) {
107
            return true;
108
        }
109
        return cameraRenderState.entityRenderState != null
110
                && cameraRenderState.entityRenderState.doesMobEffectBlockSky;
111
    }
112
113
    @Inject(method = "render", at = @At("HEAD"))
114
    private void combatant$captureIrisModelView(
115
            GraphicsResourceAllocator allocator,
116
            DeltaTracker tickCounter,
117
            boolean renderBlockOutline,
118
            net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState,
119
            org.joml.Matrix4fc positionMatrix,
120
            GpuBufferSlice fogBuffer,
121
            org.joml.Vector4f fogColor,
122
            boolean renderSky,
123
            CallbackInfo ci
124
    ) {
125
        if (positionMatrix == null) {
126
            return;
127
        }
128
129
        if (CombatantWorldMatrices.isValid()) {
130
            CombatantWorldMatrices.capturePosition(
131
                    positionMatrix,
132
                    cameraRenderState != null && cameraRenderState.pos != null
133
                            ? cameraRenderState.pos
134
                            : null
135
            );
136
        } else if (cameraRenderState != null && cameraRenderState.projectionMatrix != null) {
137
            CombatantWorldMatrices.capture(
138
                    positionMatrix,
139
                    cameraRenderState.projectionMatrix,
140
                    cameraRenderState.projectionMatrix,
141
                    cameraRenderState.pos
142
            );
143
        }
144
145
        // Refine the early GameRenderer capture with LevelRenderer's exact position matrix. The
146
        // primary source treats a second capture for the same frame as an update, so temporal
147
        // history advances exactly once and never depends on late HUD/world callbacks.
148
        var frame = CombatantRenderSystem.currentContext();
149
        if (frame != null && cameraRenderState != null && cameraRenderState.pos != null) {
150
            org.joml.Matrix4f projection = CombatantWorldMatrices.renderProjectionMatrix();
151
            org.joml.Matrix4f unjitteredProjection = CombatantWorldMatrices.unjitteredRenderProjectionMatrix();
152
            org.joml.Vector2f jitter = CombatantWorldMatrices.jitterPixels();
153
            if (projection == null) projection = cameraRenderState.projectionMatrix;
154
            if (unjitteredProjection == null) unjitteredProjection = projection;
155
            if (projection != null && unjitteredProjection != null) {
156
                CombatantRenderSystem.deferredWorld().capturePrimaryView(
157
                        frame.frameId(), positionMatrix, projection, unjitteredProjection, jitter,
158
                        cameraRenderState.pos, cameraRenderState.depthFar
159
                );
160
            }
161
162
        }
163
    }
164
165
    @Inject(
166
            method = "submitBlockOutline",
167
            at = @At("HEAD"),
168
            cancellable = true
169
    )
170
    private void combatant$disableVanillaOutline(PoseStack matrices,
171
                                                 SubmitNodeCollector consumers,
172
                                                 LevelRenderState renderState,
173
                                                 CallbackInfo ci) {
174
        BlockHighlight blockHighlight = Modules.get(BlockHighlight.class);
175
        if (blockHighlight != null && blockHighlight.isOutlineActive()) {
176
            ci.cancel();
177
        }
178
    }
179
180
    @Inject(
181
            method = "render",
182
            at = @At(
183
                    value = "INVOKE",
184
                    target = "Lnet/minecraft/client/renderer/LevelRenderer;addMainPass(Lcom/mojang/blaze3d/framegraph/FrameGraphBuilder;Lnet/minecraft/client/renderer/feature/FeatureRenderDispatcher$PreparedFrame;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;Lnet/minecraft/client/renderer/state/level/LevelRenderState;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;)V",
185
                    shift = At.Shift.AFTER
186
            )
187
    )
188
    private void combatant$captureWorldSceneDepth(
189
            GraphicsResourceAllocator allocator,
190
            DeltaTracker tickCounter,
191
            boolean renderBlockOutline,
192
            net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState,
193
            org.joml.Matrix4fc positionMatrix,
194
            GpuBufferSlice fogBuffer,
195
            org.joml.Vector4f fogColor,
196
            boolean renderSky,
197
            CallbackInfo ci,
198
            @Local FrameGraphBuilder frameGraphBuilder
199
    ) {
200
        if (IrisRuntime.isShaderpackRendererActive()) {
201
            return;
202
        }
203
        if (frameGraphBuilder == null || targets == null || targets.main == null) {
204
            return;
205
        }
206
        if (!combatant$needsWorldSceneDepthCapture()) {
207
            WorldSceneDepth.reset();
208
            return;
209
        }
210
211
        ResourceHandle<RenderTarget> main = targets.main;
212
        ResourceHandle<RenderTarget> translucent = targets.translucent;
213
        ResourceHandle<RenderTarget> itemEntity = targets.itemEntity;
214
        ResourceHandle<RenderTarget> particles = targets.particles;
215
        ResourceHandle<RenderTarget> weather = targets.weather;
216
217
        FramePass pass = frameGraphBuilder.addPass("combatant_scene_depth_capture");
218
        combatant$dependsOn(pass, main);
219
        combatant$dependsOn(pass, translucent);
220
        combatant$dependsOn(pass, itemEntity);
221
        combatant$dependsOn(pass, particles);
222
        combatant$dependsOn(pass, weather);
223
        pass.disableCulling();
224
        pass.executes(() -> {
225
            RenderTarget mainFramebuffer = combatant$getFramebuffer(main);
226
            Minecraft client = Minecraft.getInstance();
227
            RenderTarget fallbackFramebuffer = client != null ? client.gameRenderer.mainRenderTarget() : null;
228
            int width = mainFramebuffer != null ? mainFramebuffer.width : fallbackFramebuffer != null ? fallbackFramebuffer.width : 1;
229
            int height = mainFramebuffer != null ? mainFramebuffer.height : fallbackFramebuffer != null ? fallbackFramebuffer.height : 1;
230
231
            WorldSceneDepth.beginFrame(width, height);
232
            WorldSceneDepth.captureMain(mainFramebuffer);
233
            WorldSceneDepth.captureTranslucent(combatant$getFramebuffer(translucent));
234
            WorldSceneDepth.captureItemEntity(combatant$getFramebuffer(itemEntity));
235
            WorldSceneDepth.captureParticles(combatant$getFramebuffer(particles));
236
            WorldSceneDepth.captureWeather(combatant$getFramebuffer(weather));
237
        });
238
    }
239
240
    @Inject(method = "addCloudsPass", at = @At("HEAD"), cancellable = true)
241
    private void combatant$deferredOwnsClouds(
242
            FrameGraphBuilder frameGraphBuilder,
243
            CloudStatus cloudStatus,
244
            net.minecraft.world.phys.Vec3 cameraPosition,
245
            long ticks,
246
            float partialTick,
247
            int cloudColor,
248
            float cloudHeight,
249
            int renderDistance,
250
            CallbackInfo ci
251
    ) {
252
        if (cloudStatus == CloudStatus.OFF || IrisRuntime.isShaderpackRendererActive()) return;
253
        if (!CombatantRenderSystem.deferredWorld().enabled()) return;
254
        Minecraft minecraft = Minecraft.getInstance();
255
        if (minecraft == null || minecraft.level == null) return;
256
        DimensionRenderProfile profile = DimensionRenderProfileRegistry.resolve(minecraft.level.dimension());
257
        if (!CloudProfileRegistry.resolve(profile.cloudProfile()).valid()) return;
258
        ci.cancel();
259
    }
260
261
    @Inject(method = "addSkyPass", at = @At("HEAD"))
262
    private void combatant$applyVanillaSkyOverrides(FrameGraphBuilder frameGraphBuilder,
263
                                                     net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState,
264
                                                     GpuBufferSlice fog, CallbackInfo ci) {
265
        LevelRendererAccessor accessor = (LevelRendererAccessor) this;
266
        SkyRenderState sky = accessor.combatant$getWorldRenderState().skyRenderState;
267
        if (sky == null || sky.skybox != DimensionType.Skybox.OVERWORLD) return;
268
        WorldTweaks worldTweaks = Modules.get(WorldTweaks.class);
269
        if (worldTweaks != null) worldTweaks.applySkyOverrides(sky);
270
        // No cancellation: deferred OFF uses Minecraft's standard sky. Deferred sky ownership is
271
        // handled by DeferredWorldPipeline, never by the legacy ReimaginedVisual shader sky.
272
    }
273
274
    @Inject(
275
            method = "lambda$addMainPass$0",
276
            at = @At(
277
                    value = "INVOKE",
278
                    target = "Lnet/minecraft/client/renderer/chunk/ChunkSectionsToRender;renderGroup(Lnet/minecraft/client/renderer/chunk/ChunkSectionLayerGroup;Lcom/mojang/blaze3d/textures/GpuSampler;)V",
279
                    ordinal = 1,
280
                    shift = At.Shift.BEFORE
281
            ),
282
            remap = false
283
    )
284
    private void combatant$capturePreWaterScene(
285
            GpuBufferSlice fogBuffer,
286
            LevelRenderState worldRenderState,
287
            net.minecraft.util.profiling.ProfilerFiller profiler,
288
            net.minecraft.client.renderer.chunk.ChunkSectionsToRender chunkSections,
289
            com.mojang.blaze3d.resource.ResourceHandle<?> entityOutlineHandle,
290
            net.minecraft.client.renderer.feature.FeatureRenderDispatcher.PreparedFrame preparedFrame,
291
            com.mojang.blaze3d.resource.ResourceHandle<?> translucentFramebufferHandle,
292
            com.mojang.blaze3d.resource.ResourceHandle<?> mainFramebufferHandle,
293
            com.mojang.blaze3d.resource.ResourceHandle<?> itemEntityFramebufferHandle,
294
            com.mojang.blaze3d.resource.ResourceHandle<?> particlesFramebufferHandle,
295
            CallbackInfo ci
296
    ) {
297
        if (IrisRuntime.isShaderpackRendererActive()) {
298
            return;
299
        }
300
        RenderTarget mainFramebuffer = combatant$getFramebuffer(combatant$asRenderTargetHandle(mainFramebufferHandle));
301
        if (mainFramebuffer == null) {
302
            Minecraft mc = Minecraft.getInstance();
303
            mainFramebuffer = mc != null && mc.gameRenderer != null ? mc.gameRenderer.mainRenderTarget() : null;
304
        }
305
        PreTranslucentDepth.captureFrom(mainFramebuffer);
306
    }
307
}
308
LibraryMixinsrc/main/java/combatant/client/mixins/LibraryMixin.javaJava · 36 lines · 1.2 KB
@Mixin(Library.class)
ModifiesLibrary
LibraryMixin.javaJava · 36 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.audio.DeviceList;
11
import com.mojang.blaze3d.audio.Library;
12
import org.jetbrains.annotations.Nullable;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
import combatant.client.util.sound.SoundSystem;
18
19
/**
20
 * Publishes the real OpenAL lifecycle to the custom sound system.
21
 * Cleanup is performed before Minecraft destroys the current context.
22
 */
23
@Mixin(Library.class)
24
public class LibraryMixin {
25
    @Inject(method = "init", at = @At("RETURN"))
26
    private void combatant$resetOnInit(@Nullable String deviceSpecifier, DeviceList deviceList, boolean directionalAudio, CallbackInfo ci) {
27
        SoundSystem.get().onLibraryReady();
28
    }
29
30
    @Inject(method = "cleanup", at = @At("HEAD"))
31
    private void combatant$resetOnClose(CallbackInfo ci) {
32
        SoundSystem.get().onLibraryClosing();
33
    }
34
}
35
36
LightmapMixinsrc/main/java/combatant/client/mixins/LightmapMixin.javaJava · 44 lines · 1.4 KB
@Mixin(Lightmap.class)
ModifiesLightmap
LightmapMixin.javaJava · 44 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.Lightmap;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.ModifyArg;
14
import combatant.client.events.Events;
15
import combatant.client.events.impl.LightmapEvent;
16
import combatant.client.render.engine.light.LightmapState;
17
18
@Mixin(Lightmap.class)
19
public abstract class LightmapMixin {
20
21
    @ModifyArg(
22
            method = "render",
23
            at = @At(
24
                    value = "INVOKE",
25
                    target = "Lcom/mojang/blaze3d/buffers/Std140Builder;putFloat(F)Lcom/mojang/blaze3d/buffers/Std140Builder;",
26
                    ordinal = 5
27
            ),
28
            index = 0
29
    )
30
    private float combatant$ambientLightEvent(float original) {
31
        LightmapEvent event = new LightmapEvent(original);
32
        Events.BUS.post(event);
33
        float value = event.getAmbientLight();
34
35
        float base = original;
36
        float previousOverride = LightmapState.getOverrideAmbient();
37
        if (previousOverride >= 0.0f && value >= previousOverride - 1.0e-4f) {
38
            base = LightmapState.getBaseAmbient();
39
        }
40
        LightmapState.setAmbient(base, value);
41
        return value;
42
    }
43
}
44
LightmapRenderStateExtractorMixinsrc/main/java/combatant/client/mixins/LightmapRenderStateExtractorMixin.javaJava · 35 lines · 1.2 KB
@Mixin(LightmapRenderStateExtractor.class)
LightmapRenderStateExtractorMixin.javaJava · 35 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.LightmapRenderStateExtractor;
11
import net.minecraft.client.renderer.state.LightmapRenderState;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.events.Events;
17
import combatant.client.events.impl.LightmapModifyEvent;
18
import combatant.client.render.engine.light.LightmapState;
19
20
@Mixin(LightmapRenderStateExtractor.class)
21
public abstract class LightmapRenderStateExtractorMixin {
22
    @Inject(method = "extract", at = @At("TAIL"))
23
    private void combatant$modifyLightmapState(LightmapRenderState state, float tickDelta, CallbackInfo ci) {
24
        if (state == null) return;
25
26
        LightmapModifyEvent event = new LightmapModifyEvent(state);
27
        Events.BUS.post(event);
28
29
        if (event.isModified()) {
30
            state.needsUpdate = true;
31
            LightmapState.setAmbient(event.originalBrightness(), state.brightness);
32
        }
33
    }
34
}
35
LivingEntityMixinsrc/main/java/combatant/client/mixins/LivingEntityMixin.javaJava · 464 lines · 16.2 KB
@Mixin(LivingEntity.class)
ModifiesLivingEntity
LivingEntityMixin.javaJava · 464 lines · 16.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on LiquidBounce
6
 * (https://github.com/CCBlueX/LiquidBounce).
7
 * Copyright (c) 2015-2026 CCBlueX.
8
 *
9
 * LiquidBounce portions are licensed under GPLv3-or-later.
10
 * Combatant modifications are licensed under GPLv3.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins;
15
16
/*
17
 * Parts of jump rotation correction are adapted from LiquidBounce
18
 * (https://github.com/CCBlueX/LiquidBounce).
19
 * Original copyright (c) CCBlueX.
20
 */
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import net.minecraft.client.Minecraft;
25
import net.minecraft.client.player.LocalPlayer;
26
import net.minecraft.core.BlockPos;
27
import net.minecraft.core.Holder;
28
import net.minecraft.util.Mth;
29
import net.minecraft.world.damagesource.DamageSource;
30
import net.minecraft.world.effect.MobEffect;
31
import net.minecraft.world.effect.MobEffectInstance;
32
import net.minecraft.world.effect.MobEffects;
33
import net.minecraft.world.entity.LivingEntity;
34
import net.minecraft.world.entity.ai.attributes.Attribute;
35
import net.minecraft.world.entity.ai.attributes.Attributes;
36
import net.minecraft.world.entity.player.Player;
37
import net.minecraft.world.item.Item;
38
import net.minecraft.world.item.ItemStack;
39
import net.minecraft.world.level.Level;
40
import net.minecraft.world.level.block.Blocks;
41
import net.minecraft.world.level.block.state.BlockState;
42
import net.minecraft.world.phys.AABB;
43
import net.minecraft.world.phys.Vec3;
44
import org.spongepowered.asm.mixin.Mixin;
45
import org.spongepowered.asm.mixin.Shadow;
46
import org.spongepowered.asm.mixin.Unique;
47
import org.spongepowered.asm.mixin.injection.At;
48
import org.spongepowered.asm.mixin.injection.Inject;
49
import org.spongepowered.asm.mixin.injection.Redirect;
50
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
51
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
52
import combatant.client.config.values.ItemCooldownRulesValue;
53
import combatant.client.events.Events;
54
import combatant.client.events.impl.PlayerJumpEvent;
55
import combatant.client.features.module.Modules;
56
import combatant.client.features.module.modules.combat.PvpCooldowns;
57
import combatant.client.features.module.modules.combat.TPSSync;
58
import combatant.client.features.module.modules.movement.ElytraFly;
59
import combatant.client.features.module.modules.movement.NoStun;
60
import combatant.client.features.module.modules.movement.Timer;
61
import combatant.client.features.module.modules.visuals.NoRender;
62
import combatant.client.features.module.modules.visuals.WorldTweaks;
63
import combatant.client.util.aiming.RotationManager;
64
import combatant.client.util.aiming.data.Rotation;
65
import combatant.client.util.aiming.features.MovementCorrection;
66
import combatant.client.util.player.inventory.InventorySwap;
67
import combatant.client.util.pvp.client.CooldownsState;
68
import combatant.client.util.pvp.opponents.TotemPopCounter;
69
70
@Mixin(LivingEntity.class)
71
public abstract class LivingEntityMixin {
72
73
    @Unique
74
    private float combatant$itemUseRemainder = 0f;
75
76
    @Unique
77
    private float combatant$effectTickRemainder = 0f;
78
79
    @Shadow
80
    protected int useItemRemaining;
81
    @Unique
82
    private PlayerJumpEvent combatant$playerJumpEvent;
83
84
    @Shadow
85
    protected abstract float getJumpPower();
86
87
    @Inject(method = "getAttributeValue", at = @At("RETURN"))
88
    private void combatant$noStunSlownessMovementSpeed(Holder<Attribute> attribute, CallbackInfoReturnable<Double> cir) {
89
        if (!attribute.equals(Attributes.MOVEMENT_SPEED)) return;
90
        return;
91
92
    }
93
94
    @ModifyReturnValue(method = "getMainHandItem", at = @At("RETURN"))
95
    private ItemStack combatant$applyInventorySwapLeaseForMainHand(ItemStack original) {
96
        Minecraft mc = Minecraft.getInstance();
97
        if ((Object) this == mc.player) {
98
            InventorySwap.INSTANCE.isHotbarLeased();
99
        }
100
101
        return original;
102
    }
103
104
105
    /**
106
     * Optional local cooldown synthesis for servers that lock consumables without sending vanilla cooldown packets.
107
     * This never cancels item use; it only starts a visible local timer when explicitly configured.
108
     */
109
    @Inject(method = "updatingUsingItem", at = @At("HEAD"))
110
    private void combatant$onFinishEating(CallbackInfo ci) {
111
        LivingEntity self = (LivingEntity) (Object) this;
112
        Minecraft mc = Minecraft.getInstance();
113
        if (self != mc.player) return;
114
115
        ItemStack stack = self.getUseItem();
116
        if (stack == null || stack.isEmpty()) return;
117
        if (self.getUseItemRemainingTicks() != 1) return;
118
119
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
120
        if (cooldowns == null) return;
121
122
        Item item = stack.getItem();
123
        cooldowns.tryStartLocalCooldown(item, ItemCooldownRulesValue.Trigger.CONSUME_FINISH);
124
    }
125
126
    @Inject(method = "updatingUsingItem", at = @At("HEAD"), cancellable = true)
127
    private void combatant$fixItemUseSpeed(CallbackInfo ci) {
128
        LivingEntity self = (LivingEntity) (Object) this;
129
        if (!(self instanceof Player player)) {
130
            combatant$itemUseRemainder = 0f;
131
            return;
132
        }
133
134
        if (!player.level().isClientSide()) return;
135
        if (!player.isUsingItem()) {
136
            combatant$itemUseRemainder = 0f;
137
            return;
138
        }
139
140
        float scale = combatant$clientTickScale();
141
        if (scale >= 0.999f) {
142
            combatant$itemUseRemainder = 0f;
143
            return;
144
        }
145
146
        combatant$itemUseRemainder += scale;
147
        if (combatant$itemUseRemainder < 1.0f) {
148
            ci.cancel();
149
            return;
150
        }
151
152
        combatant$itemUseRemainder -= 1.0f;
153
    }
154
155
    @Redirect(
156
            method = "tickEffects",
157
            at = @At(
158
                    value = "INVOKE",
159
                    target = "Lnet/minecraft/world/effect/MobEffectInstance;tickClient()V"
160
            )
161
    )
162
    private void combatant$scaleClientEffects(MobEffectInstance instance) {
163
        LivingEntity self = (LivingEntity) (Object) this;
164
        if (!self.level().isClientSide()) {
165
            instance.tickClient();
166
            return;
167
        }
168
169
        Minecraft mc = Minecraft.getInstance();
170
        if (!(self instanceof Player player) || mc == null || player != mc.player) {
171
            instance.tickClient();
172
            return;
173
        }
174
175
        float scale = combatant$clientTickScale();
176
        if (scale >= 0.999f) {
177
            combatant$effectTickRemainder = 0f;
178
            instance.tickClient();
179
            return;
180
        }
181
182
        combatant$effectTickRemainder += scale;
183
        if (combatant$effectTickRemainder < 1.0f) {
184
            return;
185
        }
186
        combatant$effectTickRemainder -= 1.0f;
187
        instance.tickClient();
188
    }
189
190
    @Unique
191
    private float combatant$clientTickScale() {
192
        float mult = Timer.getTickTimer();
193
        if (mult <= 0.0001f) return 1.0f;
194
195
        float serverDelta = 1.0f;
196
        TPSSync tps = Modules.get(TPSSync.class);
197
        if (tps != null && tps.isEnabled()) {
198
            serverDelta = tps.getServerTickDelta();
199
        }
200
201
        float scale = serverDelta / mult;
202
        if (scale > 1.0f) return 1.0f;
203
        return Math.max(scale, 0.0f);
204
    }
205
206
    /**
207
     * Local totem cooldowns are handled from the confirmed entity-status packet when explicitly configured.
208
     */
209
    @Inject(method = "checkTotemDeathProtection", at = @At("RETURN"))
210
    private void combatant$onTotemUse(DamageSource source, CallbackInfoReturnable<Boolean> cir) {
211
        // no local use blocking or prediction here
212
    }
213
214
    /**
215
     * Сброс кулдаунов при смерти.
216
     */
217
    @Inject(method = "die", at = @At("HEAD"))
218
    private void combatant$onDeath(DamageSource source, CallbackInfo ci) {
219
        LivingEntity self = (LivingEntity) (Object) this;
220
        if (self instanceof Player player) {
221
            TotemPopCounter.onPlayerDeath(player.getUUID());
222
        }
223
224
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
225
        if (cooldowns == null || cooldowns.isSystemEnabled()) {
226
            CooldownsState.MANAGER.clear();
227
        }
228
    }
229
230
    @Inject(
231
            method = "getBlockSpeedFactor",
232
            at = @At("HEAD"),
233
            cancellable = true
234
    )
235
    private void weathercontrol$dontDampRiptide(CallbackInfoReturnable<Float> cir) {
236
        LivingEntity self = (LivingEntity) (Object) this;
237
238
        if (!(self instanceof Player player)) return;
239
        if (!player.isAutoSpinAttack()) return;
240
241
        Level world = player.level();
242
        if (world == null) return;
243
244
        if (WorldTweaks.isServerRaining(world)) {
245
            cir.setReturnValue(1.0F);
246
        }
247
    }
248
249
    @Inject(method = "aiStep", at = @At("HEAD"))
250
    private void preventCrash(CallbackInfo ci) {
251
        LivingEntity self = (LivingEntity) (Object) this;
252
253
        if (!(self instanceof Player p)) return;
254
        ElytraFly elytraFly = Modules.get(ElytraFly.class);
255
        if (elytraFly == null || !elytraFly.isEnabled()) return;
256
        if (!elytraFly.noCrash.get()) return;
257
        if (!p.isFallFlying()) return;
258
259
        Vec3 vel = p.getDeltaMovement();
260
261
        if (vel.horizontalDistance() < 1) return;
262
        AABB next = p.getBoundingBox().move(vel);
263
264
        if (!p.level().noCollision(next)) {
265
            p.setDeltaMovement(0, 0, 0);
266
        }
267
    }
268
269
    @ModifyExpressionValue(
270
            method = "updateFallFlyingMovement",
271
            at = @At(
272
                    value = "INVOKE",
273
                    target = "Lnet/minecraft/world/entity/LivingEntity;getLookAngle()Lnet/minecraft/world/phys/Vec3;"
274
            )
275
    )
276
    private Vec3 combatant$modifyGlidingRotationVector(Vec3 original) {
277
        LivingEntity self = (LivingEntity) (Object) this;
278
        Minecraft mc = Minecraft.getInstance();
279
        if (!(self instanceof LocalPlayer player) || mc == null || player != mc.player) {
280
            return original;
281
        }
282
283
        Rotation rotation = RotationManager.INSTANCE.getMovementRotation();
284
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
285
        if (rotationTarget == null
286
                || rotationTarget.movementCorrection == MovementCorrection.OFF
287
                || rotationTarget.movementCorrection == MovementCorrection.STRICT) {
288
            return original;
289
        }
290
291
        return rotation.directionVector();
292
    }
293
294
    @ModifyExpressionValue(
295
            method = "updateFallFlyingMovement",
296
            at = @At(
297
                    value = "INVOKE",
298
                    target = "Lnet/minecraft/world/entity/LivingEntity;getXRot()F"
299
            )
300
    )
301
    private float combatant$modifyGlidingPitch(float original) {
302
        LivingEntity self = (LivingEntity) (Object) this;
303
        Minecraft mc = Minecraft.getInstance();
304
        if (!(self instanceof LocalPlayer player) || mc == null || player != mc.player) {
305
            return original;
306
        }
307
308
        Rotation rotation = RotationManager.INSTANCE.getMovementRotation();
309
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
310
        if (rotationTarget == null || rotationTarget.movementCorrection == MovementCorrection.OFF) {
311
            return original;
312
        }
313
314
        return rotation.pitch();
315
    }
316
317
    @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true)
318
    private void killHasEffect(Holder<MobEffect> effect,
319
                               CallbackInfoReturnable<Boolean> cir) {
320
        NoRender noRender = Modules.get(NoRender.class);
321
        if (noRender == null || !noRender.off("bad_effects")) return;
322
323
        if (isBad(effect)) {
324
            cir.setReturnValue(false);
325
        }
326
    }
327
328
    @Inject(method = "getEffect", at = @At("HEAD"), cancellable = true)
329
    private void killGetEffect(Holder<MobEffect> effect,
330
                               CallbackInfoReturnable<MobEffectInstance> cir) {
331
        NoRender noRender = Modules.get(NoRender.class);
332
        if (noRender == null || !noRender.off("bad_effects")) return;
333
334
        if (isBad(effect)) {
335
            cir.setReturnValue(null);
336
        }
337
    }
338
339
    @Inject(method = "jumpFromGround", at = @At("HEAD"), cancellable = true)
340
    private void combatant$onJumpHead(CallbackInfo ci) {
341
        LivingEntity self = (LivingEntity) (Object) this;
342
        if (!(self instanceof LocalPlayer player)) {
343
            combatant$playerJumpEvent = null;
344
            return;
345
        }
346
347
        Minecraft mc = Minecraft.getInstance();
348
        if (mc == null || player != mc.player) {
349
            combatant$playerJumpEvent = null;
350
            return;
351
        }
352
353
        PlayerJumpEvent event = new PlayerJumpEvent(self.getYRot(), getJumpPower());
354
        Events.BUS.post(event);
355
        if (event.isCancelled()) {
356
            combatant$playerJumpEvent = null;
357
            ci.cancel();
358
            return;
359
        }
360
361
        combatant$playerJumpEvent = event;
362
    }
363
364
    @ModifyExpressionValue(
365
            method = "jumpFromGround",
366
            at = @At(
367
                    value = "INVOKE",
368
                    target = "Lnet/minecraft/world/entity/LivingEntity;getJumpPower()F"
369
            )
370
    )
371
    private float combatant$modifyJumpMotion(float original) {
372
        return combatant$playerJumpEvent != null ? combatant$playerJumpEvent.getMotion() : original;
373
    }
374
375
    @ModifyExpressionValue(
376
            method = "jumpFromGround",
377
            at = @At(
378
                    value = "NEW",
379
                    target = "(DDD)Lnet/minecraft/world/phys/Vec3;"
380
            )
381
    )
382
    private Vec3 combatant$fixJumpRotation(Vec3 original) {
383
        LivingEntity self = (LivingEntity) (Object) this;
384
        Minecraft mc = Minecraft.getInstance();
385
        if (!(self instanceof LocalPlayer player) || mc == null || player != mc.player) {
386
            return original;
387
        }
388
389
        Rotation rotation = RotationManager.INSTANCE.getMovementRotation();
390
        var rotationTarget = RotationManager.INSTANCE.getActiveRotationTarget();
391
        if (rotationTarget == null || rotationTarget.movementCorrection == MovementCorrection.OFF) {
392
            return original;
393
        }
394
395
        float yaw = rotation.yaw() * Mth.DEG_TO_RAD;
396
        return new Vec3(-Mth.sin(yaw) * 0.2F, 0.0, Mth.cos(yaw) * 0.2F);
397
    }
398
399
    @Redirect(
400
            method = "jumpFromGround",
401
            at = @At(
402
                    value = "INVOKE",
403
                    target = "Lnet/minecraft/world/entity/LivingEntity;getYRot()F"
404
            )
405
    )
406
    private float combatant$omniSprintJumpYaw(LivingEntity instance) {
407
        return combatant$playerJumpEvent != null ? combatant$playerJumpEvent.getYaw() : instance.getYRot();
408
    }
409
410
    @Inject(method = "jumpFromGround", at = @At("RETURN"))
411
    private void combatant$onJumpReturn(CallbackInfo ci) {
412
        combatant$playerJumpEvent = null;
413
    }
414
415
    @Unique
416
    private boolean isBad(Holder<MobEffect> entry) {
417
        MobEffect eff = entry.value();
418
        return eff == MobEffects.BLINDNESS.value()
419
                || eff == MobEffects.DARKNESS.value()
420
                || eff == MobEffects.NAUSEA.value();
421
    }
422
423
    @Inject(
424
            method = "getBlockSpeedFactor",
425
            at = @At("RETURN"),
426
            cancellable = true
427
    )
428
    private void nostun$soulSandVelocity(CallbackInfoReturnable<Float> cir) {
429
        LivingEntity self = (LivingEntity) (Object) this;
430
        if (!(self instanceof Player player)) return;
431
        Minecraft client = Minecraft.getInstance();
432
        if (client == null || player != client.player) return;
433
434
        NoStun ns = Modules.get(NoStun.class);
435
        if (ns == null || !ns.isEnabled()) return;
436
        if (ns.isVulcan297()) {
437
            BlockPos pos = player.blockPosition();
438
            BlockState state = player.level().getBlockState(pos);
439
            if (state.is(Blocks.SOUL_SAND)) {
440
                cir.setReturnValue(ns.getSoulSandVelocityMultiplier(cir.getReturnValue()));
441
            }
442
            return;
443
        }
444
445
        // общий тумблер env
446
        if (!ns.isFunctionEnabled(NoStun.fnEnvBlocks())) return;
447
448
        // конкретный тумблер песка душ
449
        if (!ns.isEnvBlockEnabled(NoStun.envSoulSand())) return;
450
451
        BlockPos pos = player.blockPosition();
452
        BlockState state = player.level().getBlockState(pos);
453
454
        if (!state.is(Blocks.SOUL_SAND)) return;
455
456
        float vanilla = cir.getReturnValue();
457
458
        if (vanilla < 1.0F) {
459
            cir.setReturnValue(1.0F);
460
        }
461
    }
462
463
}
464
LivingEntityRenderStateMixinsrc/main/java/combatant/client/mixins/LivingEntityRenderStateMixin.javaJava · 71 lines · 2.0 KB
@Mixin(LivingEntityRenderState.class)
LivingEntityRenderStateMixin.javaJava · 71 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Unique;
13
import combatant.client.render.ViewObstructionFadeState;
14
import combatant.client.features.playeranimator.PlayerRigInstance;
15
import combatant.client.features.playeranimator.PlayerRigRenderState;
16
17
@Mixin(LivingEntityRenderState.class)
18
public abstract class LivingEntityRenderStateMixin implements ViewObstructionFadeState, PlayerRigRenderState {
19
    @Unique
20
    private boolean combatant$viewObstructionFadeActive;
21
22
    @Unique
23
    private float combatant$viewObstructionFadeAlpha = 1.0f;
24
25
    @Unique
26
    private boolean combatant$seeInvisibleFadeActive;
27
28
    @Unique
29
    private PlayerRigInstance combatant$playerRig;
30
31
    @Override
32
    public boolean combatant$isViewObstructionFadeActive() {
33
        return combatant$viewObstructionFadeActive;
34
    }
35
36
    @Override
37
    public float combatant$getViewObstructionFadeAlpha() {
38
        return combatant$viewObstructionFadeAlpha;
39
    }
40
41
    @Override
42
    public void combatant$setViewObstructionFadeActive(boolean active) {
43
        this.combatant$viewObstructionFadeActive = active;
44
    }
45
46
    @Override
47
    public void combatant$setViewObstructionFadeAlpha(float alpha) {
48
        this.combatant$viewObstructionFadeAlpha = alpha;
49
    }
50
51
    @Override
52
    public boolean combatant$isSeeInvisibleFadeActive() {
53
        return combatant$seeInvisibleFadeActive;
54
    }
55
56
    @Override
57
    public void combatant$setSeeInvisibleFadeActive(boolean active) {
58
        this.combatant$seeInvisibleFadeActive = active;
59
    }
60
61
    @Override
62
    public PlayerRigInstance combatant$getPlayerRig() {
63
        return combatant$playerRig;
64
    }
65
66
    @Override
67
    public void combatant$setPlayerRig(PlayerRigInstance rig) {
68
        this.combatant$playerRig = rig;
69
    }
70
}
71
LivingEntityRendererMixinsrc/main/java/combatant/client/mixins/LivingEntityRendererMixin.javaJava · 280 lines · 13.0 KB
@Mixin(LivingEntityRenderer.class)
LivingEntityRendererMixin.javaJava · 280 lines · 13.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
12
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
13
import com.llamalad7.mixinextras.sugar.Local;
14
import com.mojang.blaze3d.vertex.PoseStack;
15
import combatant.client.features.module.modules.visuals.ViewModel;
16
import combatant.client.util.screen.ClientScreen;
17
import combatant.client.features.playeranimator.PlayerRigRenderContext;
18
import combatant.client.features.playeranimator.PlayerRigRenderState;
19
import combatant.client.features.playeranimator.render.PlayerRigCpuRenderer;
20
import net.minecraft.client.model.Model;
21
import net.minecraft.client.model.HumanoidModel;
22
import net.minecraft.client.model.player.PlayerModel;
23
import net.minecraft.client.Minecraft;
24
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
25
import net.minecraft.client.player.LocalPlayer;
26
import net.minecraft.client.renderer.entity.EntityRenderer;
27
import net.minecraft.client.renderer.entity.EntityRendererProvider;
28
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
29
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
30
import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
31
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
32
import net.minecraft.client.renderer.SubmitNodeCollector;
33
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
34
import net.minecraft.client.renderer.rendertype.RenderType;
35
import net.minecraft.client.renderer.rendertype.RenderTypes;
36
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
37
import net.minecraft.resources.Identifier;
38
import net.minecraft.util.Mth;
39
import net.minecraft.world.entity.LivingEntity;
40
import net.minecraft.world.entity.player.Player;
41
import org.spongepowered.asm.mixin.Mixin;
42
import org.spongepowered.asm.mixin.injection.At;
43
import org.spongepowered.asm.mixin.injection.Constant;
44
import org.spongepowered.asm.mixin.injection.Inject;
45
import org.spongepowered.asm.mixin.injection.ModifyConstant;
46
import org.spongepowered.asm.mixin.Shadow;
47
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
48
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
49
import combatant.client.features.module.Modules;
50
import combatant.client.features.module.modules.visuals.NameTags;
51
import combatant.client.features.module.modules.visuals.NoRender;
52
import combatant.client.features.module.modules.visuals.SeeInvisibles;
53
import combatant.client.render.ViewObstructionFadeContext;
54
import combatant.client.render.ViewObstructionFadeState;
55
import combatant.client.render.iris.IrisRuntime;
56
import combatant.client.util.aiming.RotationManager;
57
import combatant.client.util.aiming.data.Rotation;
58
59
@Mixin(LivingEntityRenderer.class)
60
public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState> extends EntityRenderer<T, S> {
61
    protected LivingEntityRendererMixin(EntityRendererProvider.Context ctx) {
62
        super(ctx);
63
    }
64
65
    @Shadow
66
    public abstract Identifier getTextureLocation(S state);
67
68
    @Inject(
69
            method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z",
70
            at = @At("HEAD"),
71
            cancellable = true
72
    )
73
    private void combatant$hideVanillaLabels(T entity, double distanceSq, CallbackInfoReturnable<Boolean> cir) {
74
        if (!(entity instanceof Player)) {
75
            return;
76
        }
77
78
        NameTags nameTags = Modules.get(NameTags.class);
79
        NoRender noRender = Modules.get(NoRender.class);
80
        if ((nameTags != null && nameTags.isEnabled())
81
                || (noRender != null && noRender.offEntity("player_name_tags"))) {
82
            cir.setReturnValue(false);
83
        }
84
    }
85
86
@Inject(
87
            method = "submit(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
88
            at = @At("HEAD"),
89
            cancellable = true
90
    )
91
    private void combatant$noRenderArmorStand(
92
            S state,
93
            PoseStack poseStack,
94
            SubmitNodeCollector collector,
95
            net.minecraft.client.renderer.state.level.CameraRenderState cameraState,
96
            CallbackInfo ci
97
    ) {
98
        NoRender noRender = Modules.get(NoRender.class);
99
        if (!(state instanceof ArmorStandRenderState)
100
                || noRender == null
101
                || !noRender.offEntity("armor_stands")) {
102
            return;
103
        }
104
105
        if (state.nameTag != null) {
106
            this.submitNameDisplay(state, poseStack, collector, cameraState);
107
        }
108
        ci.cancel();
109
    }
110
111
    @Inject(
112
            method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V",
113
            at = @At("TAIL")
114
    )
115
    private void combatant$updateViewObstructionFadeState(T entity, S state, float tickProgress, CallbackInfo ci) {
116
        if (!(state instanceof ViewObstructionFadeState fadeState)) {
117
            return;
118
        }
119
120
        NoRender noRender = Modules.get(NoRender.class);
121
        boolean obstructionFadeActive = noRender != null && noRender.shouldFadeEntity(entity);
122
        float obstructionFadeAlpha = obstructionFadeActive ? noRender.getEntityFadeAlpha(entity) : 1.0f;
123
        obstructionFadeActive = obstructionFadeActive && obstructionFadeAlpha < 0.99f;
124
125
        SeeInvisibles seeInvisibles = Modules.get(SeeInvisibles.class);
126
        boolean seeInvisibleActive = seeInvisibles != null && seeInvisibles.shouldRenderInvisiblePlayer(entity);
127
        float seeInvisibleAlpha = seeInvisibleActive ? seeInvisibles.getInvisiblePlayerAlpha01() : 1.0f;
128
        boolean seeInvisibleFadeActive = seeInvisibleActive && seeInvisibleAlpha < 0.99f;
129
        if (seeInvisibleActive) {
130
            state.isInvisibleToPlayer = false;
131
        }
132
133
        boolean active = obstructionFadeActive || seeInvisibleFadeActive;
134
        float alpha = obstructionFadeAlpha;
135
        if (seeInvisibleFadeActive) {
136
            alpha = Math.min(alpha, seeInvisibleAlpha);
137
        }
138
        fadeState.combatant$setViewObstructionFadeActive(active);
139
        fadeState.combatant$setViewObstructionFadeAlpha(active ? alpha : 1.0f);
140
        fadeState.combatant$setSeeInvisibleFadeActive(seeInvisibleFadeActive);
141
    }
142
143
    @WrapOperation(
144
            method = "submit",
145
            at = @At(
146
                    value = "INVOKE",
147
                    target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;ILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"
148
            )
149
    )
150
    private void combatant$submitAnatomicalPlayer(
151
            SubmitNodeCollector collector,
152
            Model<?> model,
153
            Object modelState,
154
            PoseStack matrices,
155
            RenderType renderType,
156
            int light,
157
            int overlay,
158
            int tint,
159
            TextureAtlasSprite sprite,
160
            int outlineColor,
161
            ModelFeatureRenderer.CrumblingOverlay crumbling,
162
            Operation<Void> original
163
    ) {
164
        if (model instanceof PlayerModel playerModel
165
                && modelState instanceof AvatarRenderState avatarState
166
                && avatarState instanceof PlayerRigRenderState rigState
167
                && PlayerRigCpuRenderer.submitPlayer(
168
                        collector, playerModel, avatarState, rigState.combatant$getPlayerRig(), matrices,
169
                        renderType, light, overlay, tint, sprite, outlineColor, crumbling
170
                )) {
171
            return;
172
        }
173
        original.call(collector, model, modelState, matrices, renderType, light, overlay, tint,
174
                sprite, outlineColor, crumbling);
175
    }
176
177
    @ModifyExpressionValue(
178
            method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V",
179
            at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;rotLerp(FFF)F")
180
    )
181
    private float combatant$renderRotationYaw(float original, @Local(argsOnly = true) T entity, @Local(argsOnly = true) float tickProgress) {
182
        if (!(entity instanceof LocalPlayer player)) {
183
            return original;
184
        }
185
186
        Minecraft mc = Minecraft.getInstance();
187
        if (mc.player != player || ClientScreen.current() instanceof AbstractContainerScreen<?>) {
188
            return original;
189
        }
190
191
        Rotation current = RotationManager.INSTANCE.getCurrentRotation();
192
        Rotation previous = RotationManager.INSTANCE.getPreviousRotation();
193
        if (current == null) {
194
            return original;
195
        }
196
197
        float prevYaw = previous != null ? previous.yaw() : current.yaw();
198
        if (prevYaw == player.getYRot() && current.yaw() == player.getYRot()) {
199
            return original;
200
        }
201
202
        return Mth.rotLerp(tickProgress, prevYaw, current.yaw());
203
    }
204
205
    @ModifyExpressionValue(
206
            method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V",
207
            at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getXRot(F)F")
208
    )
209
    private float combatant$renderRotationPitch(float original, @Local(argsOnly = true) T entity, @Local(argsOnly = true) float tickProgress) {
210
        if (!(entity instanceof LocalPlayer player)) {
211
            return original;
212
        }
213
214
        Minecraft mc = Minecraft.getInstance();
215
        if (mc.player != player || ClientScreen.current() instanceof AbstractContainerScreen<?>) {
216
            return original;
217
        }
218
219
        Rotation current = RotationManager.INSTANCE.getCurrentRotation();
220
        Rotation previous = RotationManager.INSTANCE.getPreviousRotation();
221
        if (current == null) {
222
            return original;
223
        }
224
225
        float prevPitch = previous != null ? previous.pitch() : current.pitch();
226
        if (prevPitch == player.getXRot() && current.pitch() == player.getXRot()) {
227
            return original;
228
        }
229
230
        return Mth.lerp(tickProgress, prevPitch, current.pitch());
231
    }
232
233
234
    @ModifyExpressionValue(
235
            method = "submit",
236
            at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;getRenderType(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;ZZZ)Lnet/minecraft/client/renderer/rendertype/RenderType;")
237
    )
238
    private RenderType combatant$useTranslucentRenderTypeForViewFade(RenderType original, @Local(argsOnly = true) S state) {
239
        if (original == null || original.hasBlending()) {
240
            return original;
241
        }
242
        if (IrisRuntime.isRenderingShadowPass()) {
243
            return original;
244
        }
245
        if (!(state instanceof ViewObstructionFadeState fadeState)
246
                || !fadeState.combatant$isViewObstructionFadeActive()
247
                || fadeState.combatant$getViewObstructionFadeAlpha() >= 0.99f) {
248
            return original;
249
        }
250
        return RenderTypes.entityTranslucent(getTextureLocation(state), true);
251
    }
252
253
    @ModifyConstant(
254
            method = "submit",
255
            constant = @Constant(intValue = 654311423)
256
    )
257
    private int combatant$seeInvisibles$overrideInvisiblePlayerAlpha(int vanillaTint, S state) {
258
        SeeInvisibles seeInvisibles = Modules.get(SeeInvisibles.class);
259
        if (seeInvisibles != null
260
                && state instanceof ViewObstructionFadeState fadeState
261
                && fadeState.combatant$isSeeInvisibleFadeActive()
262
                && seeInvisibles.shouldRenderInvisiblePlayer(state.entityType, state.isInvisible)) {
263
            return seeInvisibles.getInvisiblePlayerTintArgb();
264
        }
265
        return vanillaTint;
266
    }
267
268
    @Inject(method = "submit", at = @At("HEAD"))
269
    private void combatant$pushViewObstructionFadeContext(S state, com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.SubmitNodeCollector orderedRenderCommandQueue, net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState, CallbackInfo ci) {
270
        ViewObstructionFadeContext.push(state instanceof ViewObstructionFadeState fadeState ? fadeState : null);
271
        PlayerRigRenderContext.push(state);
272
    }
273
274
    @Inject(method = "submit", at = @At("RETURN"))
275
    private void combatant$popViewObstructionFadeContext(S state, com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.SubmitNodeCollector orderedRenderCommandQueue, net.minecraft.client.renderer.state.level.CameraRenderState cameraRenderState, CallbackInfo ci) {
276
        PlayerRigRenderContext.pop();
277
        ViewObstructionFadeContext.pop();
278
    }
279
}
280
LocalPlayerMixinsrc/main/java/combatant/client/mixins/LocalPlayerMixin.javaJava · 904 lines · 30.2 KB
@Mixin(LocalPlayer.class)
ModifiesLocalPlayer
LocalPlayerMixin.javaJava · 904 lines · 30.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on LiquidBounce
6
 * (https://github.com/CCBlueX/LiquidBounce).
7
 * Copyright (c) 2015-2026 CCBlueX.
8
 *
9
 * LiquidBounce portions are licensed under GPLv3-or-later.
10
 * Combatant modifications are licensed under GPLv3.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins;
15
16
/*
17
 * Parts of sprint control, silent rotations, and movement-input correction
18
 * are adapted from LiquidBounce (https://github.com/CCBlueX/LiquidBounce).
19
 * Original copyright (c) CCBlueX.
20
 */
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import combatant.client.events.impl.*;
24
import combatant.client.features.module.modules.movement.*;
25
import combatant.client.util.combat.SprintController;
26
import combatant.client.util.screen.ClientScreen;
27
import net.minecraft.client.player.ClientInput;
28
import net.minecraft.client.player.LocalPlayer;
29
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
30
import net.minecraft.util.Mth;
31
import net.minecraft.world.entity.Entity;
32
import net.minecraft.world.entity.LivingEntity;
33
import net.minecraft.world.entity.PortalProcessor;
34
import net.minecraft.world.entity.player.Input;
35
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl;
36
import net.minecraft.world.inventory.InventoryMenu;
37
import net.minecraft.world.level.entity.EntityTypeTest;
38
import net.minecraft.world.phys.Vec2;
39
import net.minecraft.world.phys.Vec3;
40
import org.spongepowered.asm.mixin.Mixin;
41
import org.spongepowered.asm.mixin.Shadow;
42
import org.spongepowered.asm.mixin.Unique;
43
import org.spongepowered.asm.mixin.injection.At;
44
import org.spongepowered.asm.mixin.injection.Inject;
45
import org.spongepowered.asm.mixin.injection.Redirect;
46
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
47
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
48
import combatant.client.events.Events;
49
import combatant.client.events.impl.*;
50
import combatant.client.features.module.Modules;
51
import combatant.client.features.module.modules.movement.*;
52
import combatant.client.features.module.modules.player.XCarry;
53
import combatant.client.features.module.modules.visuals.Freecam;
54
import combatant.client.mixininterface.ILocalPlayer;
55
import combatant.client.mixins.accessors.EntityAccessor;
56
import combatant.client.mixins.accessors.InputAccessor;
57
import combatant.client.mixins.accessors.LocalPlayerAccessor;
58
import combatant.client.runtime.RuntimeGate;
59
import combatant.client.util.aiming.RotationManager;
60
import combatant.client.util.aiming.data.Rotation;
61
62
import java.util.ArrayList;
63
import java.util.List;
64
65
@Mixin(LocalPlayer.class)
66
public abstract class LocalPlayerMixin implements ILocalPlayer {
67
68
    @Shadow
69
    public ClientInput input;
70
    @Unique
71
    private float combatant$lastYaw;
72
    @Unique
73
    private float combatant$lastPitch;
74
    @Unique
75
    private double combatant$rotationPrevX;
76
    @Unique
77
    private double combatant$rotationPrevZ;
78
    @Unique
79
    private float combatant$rotationPrevBodyYaw;
80
    @Unique
81
    private boolean combatant$rotationBodyYawInitialized;
82
    @Unique
83
    private float freecam$lastHealth = Float.NaN;
84
    @Unique
85
    private boolean frozen = false;
86
    @Unique
87
    private Vec3 savedVelocity = Vec3.ZERO;
88
    @Unique
89
    private double savedX, savedY, savedZ;
90
    @Unique
91
    private float savedBodyYaw;
92
    @Unique
93
    private float savedHeadYaw;
94
    @Unique
95
    private Runnable combatant$eventPostAction;
96
    @Unique
97
    private EventSync combatant$activeSyncEvent;
98
    @Unique
99
    private boolean combatant$postUpdateLock = false;
100
    @Unique
101
    private Input lastInput;
102
    @Unique
103
    private boolean pendingSpoof = false;
104
    @Unique
105
    private int boostTicks = 0;
106
    @Unique
107
    private double boostX = 0, boostZ = 0;
108
    @Unique
109
    private boolean wasGround = true;
110
111
    @Unique
112
    private static boolean combatant$sameInput(Input a, Input b) {
113
        if (a == b) return true;
114
        if (a == null || b == null) return false;
115
116
        return a.forward() == b.forward()
117
                && a.backward() == b.backward()
118
                && a.left() == b.left()
119
                && a.right() == b.right()
120
                && a.jump() == b.jump()
121
                && a.shift() == b.shift()
122
                && a.sprint() == b.sprint();
123
    }
124
125
    @Unique
126
    private static float combatant$impulse(boolean positive, boolean negative) {
127
        if (positive == negative) {
128
            return 0.0f;
129
        }
130
        return positive ? 1.0f : -1.0f;
131
    }
132
133
    @Unique
134
    private static float combatant$simulateBodyYaw(
135
            float yaw,
136
            float prevBodyYaw,
137
            double prevX,
138
            double prevZ,
139
            double currentX,
140
            double currentZ,
141
            float handSwingProgress
142
    ) {
143
        double motionX = currentX - prevX;
144
        double motionZ = currentZ - prevZ;
145
        float motionSquared = (float) (motionX * motionX + motionZ * motionZ);
146
        float bodyYaw = prevBodyYaw;
147
148
        if (motionSquared > 0.0025000002F) {
149
            float movementYaw = (float) Mth.atan2(motionZ, motionX) * Mth.RAD_TO_DEG - 90.0F;
150
            float yawDiff = Math.abs(Mth.wrapDegrees(yaw) - movementYaw);
151
            bodyYaw = (yawDiff > 95.0F && yawDiff < 265.0F) ? movementYaw - 180.0F : movementYaw;
152
        }
153
154
        if (handSwingProgress - 0.2F > 0.0F) {
155
            bodyYaw = yaw;
156
        }
157
158
        float deltaYaw = Mth.wrapDegrees(bodyYaw - prevBodyYaw);
159
        bodyYaw = prevBodyYaw + deltaYaw * 0.3F;
160
161
        float yawOffsetDiff = Mth.wrapDegrees(yaw - bodyYaw);
162
        float maxHeadRotation = 52.0F;
163
        if (Math.abs(yawOffsetDiff) > maxHeadRotation) {
164
            bodyYaw += yawOffsetDiff - Math.signum(yawOffsetDiff) * maxHeadRotation;
165
        }
166
167
        return bodyYaw;
168
    }
169
170
    @Inject(method = "tick", at = @At("HEAD"))
171
    private void combatant$cacheLastRotations(CallbackInfo ci) {
172
        LocalPlayer self = (LocalPlayer) (Object) this;
173
        combatant$lastYaw = self.getYRot();
174
        combatant$lastPitch = self.getXRot();
175
        RotationManager.INSTANCE.runTickLifecycle();
176
        if (!combatant$rotationBodyYawInitialized) {
177
            combatant$rotationPrevX = self.getX();
178
            combatant$rotationPrevZ = self.getZ();
179
            combatant$rotationPrevBodyYaw = self.getVisualRotationYInDegrees();
180
            combatant$rotationBodyYawInitialized = true;
181
        }
182
    }
183
184
    @Inject(method = "handlePortalTransitionEffect", at = @At("HEAD"), cancellable = true)
185
    private void combatant$disablePortalNausea(boolean inPortal, CallbackInfo ci) {
186
        if (RuntimeGate.isPanic()) return;
187
        LocalPlayer self = (LocalPlayer) (Object) this;
188
        PortalProcessor portalManager = null;
189
        if (self instanceof EntityAccessor accessor) {
190
            portalManager = accessor.combatant$getPortalManager();
191
        }
192
        if (portalManager != null && portalManager.isInsidePortalThisTick()) {
193
            if (self instanceof LocalPlayerAccessor accessor) {
194
                accessor.combatant$setNauseaIntensity(0.0f);
195
                accessor.combatant$setLastNauseaIntensity(0.0f);
196
            }
197
            ci.cancel();
198
        }
199
    }
200
201
    @Override
202
    public float combatant$getLastYaw() {
203
        return combatant$lastYaw;
204
    }
205
206
    @Override
207
    public float combatant$getLastPitch() {
208
        return combatant$lastPitch;
209
    }
210
211
    @Override
212
    public void combatant$setLastYaw(float yaw) {
213
        this.combatant$lastYaw = yaw;
214
    }
215
216
    @Override
217
    public void combatant$setLastPitch(float pitch) {
218
        this.combatant$lastPitch = pitch;
219
    }
220
221
    @ModifyExpressionValue(
222
            method = "aiStep",
223
            at = @At(
224
                    value = "INVOKE",
225
                    target = "Lnet/minecraft/client/player/LocalPlayer;canStartSprinting()Z"
226
            )
227
    )
228
    private boolean combatant$sprintMovementStart(boolean original) {
229
        return combatant$postSprintControl(original, SprintControlEvent.Source.MOVEMENT_TICK);
230
    }
231
232
    @ModifyExpressionValue(
233
            method = "aiStep",
234
            at = @At(
235
                    value = "INVOKE",
236
                    target = "Lnet/minecraft/world/entity/player/Input;sprint()Z"
237
            )
238
    )
239
    private boolean combatant$sprintMovementInput(boolean original) {
240
        return combatant$postSprintControl(original, SprintControlEvent.Source.MOVEMENT_TICK);
241
    }
242
243
    @ModifyExpressionValue(
244
            method = "sendIsSprintingIfNeeded",
245
            at = @At(
246
                    value = "INVOKE",
247
                    target = "Lnet/minecraft/client/player/LocalPlayer;isSprinting()Z"
248
            )
249
    )
250
    private boolean combatant$sprintNetwork(boolean original) {
251
        if (SprintController.INSTANCE.isSprintBlocked()) {
252
            return false;
253
        }
254
255
        return original;
256
    }
257
258
    @Unique
259
    private boolean combatant$postSprintControl(boolean original, SprintControlEvent.Source source) {
260
        LocalPlayer self = (LocalPlayer) (Object) this;
261
262
        if (self.input == null) {
263
            return original;
264
        }
265
266
        if (!Events.BUS.hasListeners(SprintControlEvent.class)) {
267
            return original;
268
        }
269
270
        Vec2 movement = self.input.getMoveVector();
271
        SprintControlEvent event = new SprintControlEvent(
272
                movement.y,
273
                movement.x,
274
                original,
275
                source
276
        );
277
        Events.BUS.post(event);
278
        return event.shouldSprint();
279
    }
280
281
    @Inject(method = "modifyInput", at = @At("RETURN"), cancellable = true)
282
    private void boostWhenUsing(Vec2 input, CallbackInfoReturnable<Vec2> cir) {
283
        NoStun ns = Modules.get(NoStun.class);
284
        if (ns == null || !ns.isEnabled()) return;
285
        if (!ns.isFunctionEnabled(NoStun.fnUseSpeed())) return;
286
287
        LocalPlayer player = (LocalPlayer) (Object) this;
288
        if (player.isUsingItem() && !player.isPassenger()) {
289
            Vec2 base = cir.getReturnValue();
290
291
            // 0.0 -> vanilla (no change), 1.0 -> normal walking speed.
292
            // Vanilla item-use slowdown is typically ~0.2x; lerp 1..5 approximates reciprocal compensation.
293
            float t = ns.getEatSpeed01();
294
            float mult = 1.0f + t * 4.0f;
295
296
            if (mult > 1.001f) {
297
                cir.setReturnValue(base.scale(mult));
298
            }
299
        }
300
    }
301
302
    @Inject(method = "aiStep", at = @At("HEAD"))
303
    private void combatant$elytraFlyVanilla(CallbackInfo ci) {
304
        LocalPlayer player = (LocalPlayer) (Object) this;
305
        ElytraFly elytraFly = Modules.get(ElytraFly.class);
306
        if (elytraFly == null || !elytraFly.shouldApplyVanillaHook(player)) {
307
            return;
308
        }
309
310
        Vec3 velocity = player.getDeltaMovement();
311
        Vec3 look = player.getViewVector(1.0f);
312
        float pitch = player.getXRot();
313
314
        velocity = velocity.scale(elytraFly.getVanillaDragFactor());
315
        velocity = velocity.add(look.scale(elytraFly.getVanillaForwardBoostFactor()));
316
317
        double lift = -Math.sin(Math.toRadians(pitch)) * elytraFly.getVanillaPitchLiftFactor();
318
        player.setDeltaMovement(velocity.add(0.0, lift, 0.0));
319
    }
320
321
    @Shadow
322
    protected abstract void sendPosition();
323
324
    @Inject(method = "applyInput", at = @At("HEAD"), cancellable = true)
325
    private void freecam$blockWASD(CallbackInfo ci) {
326
        Freecam fc = Modules.get(Freecam.class);
327
        if (fc != null && fc.isEnabled() && fc.isCameraInput()) {
328
            ci.cancel();
329
        }
330
    }
331
332
    @Inject(
333
            method = "aiStep",
334
            at = @At(
335
                    value = "INVOKE",
336
                    target = "Lnet/minecraft/client/player/ClientInput;tick()V",
337
                    shift = At.Shift.AFTER
338
            )
339
    )
340
    private void freecam$afterInputTick(CallbackInfo ci) {
341
        Freecam fc = Modules.get(Freecam.class);
342
        if (fc == null || !fc.isEnabled() || !fc.isCameraInput()) return;
343
344
        ((InputAccessor) this.input).setMovementVector(Vec2.ZERO);
345
346
        boolean sneak = false;
347
        boolean sprint = this.input.keyPresses.sprint();
348
349
        this.input.keyPresses = new Input(
350
                false, false, false, false,
351
                false,
352
                sneak,
353
                sprint
354
        );
355
    }
356
357
    @Inject(
358
            method = "aiStep",
359
            at = @At(
360
                    value = "INVOKE",
361
                    target = "Lnet/minecraft/client/player/ClientInput;tick()V",
362
                    shift = At.Shift.AFTER
363
            )
364
    )
365
    private void combatant$afterInputTickSprint(CallbackInfo ci) {
366
        if (this.input == null) return;
367
368
        Input original = this.input.keyPresses;
369
        if (original == null) return;
370
371
        Input input = original;
372
373
        if (Events.BUS.hasListeners(MovementInputEvent.class)) {
374
            MovementInputEvent event = new MovementInputEvent(input);
375
            Events.BUS.post(event);
376
377
            Input eventInput = event.toPlayerInput();
378
            if (!combatant$sameInput(input, eventInput)) {
379
                input = eventInput;
380
            }
381
        }
382
383
        Input transformedInput = combatant$transformDirection(input);
384
        if (!combatant$sameInput(input, transformedInput)) {
385
            input = transformedInput;
386
        }
387
388
        if (Events.BUS.hasListeners(SprintControlEvent.class)) {
389
            float forward = combatant$impulse(input.forward(), input.backward());
390
            float sideways = combatant$impulse(input.left(), input.right());
391
392
            SprintControlEvent event = new SprintControlEvent(
393
                    forward,
394
                    sideways,
395
                    input.sprint(),
396
                    SprintControlEvent.Source.INPUT
397
            );
398
            Events.BUS.post(event);
399
400
            if (event.shouldSprint() != input.sprint()) {
401
                input = new Input(
402
                        input.forward(),
403
                        input.backward(),
404
                        input.left(),
405
                        input.right(),
406
                        input.jump(),
407
                        input.shift(),
408
                        event.shouldSprint()
409
                );
410
            }
411
        }
412
413
        if (!combatant$sameInput(original, input)) {
414
            combatant$applyPlayerInput(input);
415
        }
416
    }
417
418
    @Unique
419
    private void combatant$applyPlayerInput(Input input) {
420
        if (this.input == null || input == null) {
421
            return;
422
        }
423
424
        InputAccessor accessor = (InputAccessor) this.input;
425
        accessor.setPlayerInput(input);
426
427
        float forward = combatant$impulse(input.forward(), input.backward());
428
        float sideways = combatant$impulse(input.left(), input.right());
429
430
        accessor.setMovementVector(new Vec2(sideways, forward).normalized());
431
    }
432
433
    @Unique
434
    private Input combatant$transformDirection(Input input) {
435
        // Post-input hook remains inert to avoid double-transforming movement input.
436
        return input;
437
    }
438
439
    @Redirect(
440
            method = "aiStep",
441
            at = @At(
442
                    value = "INVOKE",
443
                    target = "Lnet/minecraft/world/entity/player/Input;shift()Z",
444
                    ordinal = 0
445
            )
446
    )
447
    private boolean freecam$noFlyDown0(Input in) {
448
        Freecam fc = Modules.get(Freecam.class);
449
        if (fc != null && fc.isEnabled() && fc.isCameraInput()) {
450
            LocalPlayer self = (LocalPlayer) (Object) this;
451
            if (self.getAbilities().flying) return false;
452
        }
453
        return in.shift();
454
    }
455
456
    @Redirect(
457
            method = "aiStep",
458
            at = @At(
459
                    value = "INVOKE",
460
                    target = "Lnet/minecraft/world/entity/player/Input;shift()Z",
461
                    ordinal = 1
462
            ),
463
            require = 0
464
    )
465
    private boolean freecam$noFlyDown1(Input in) {
466
        Freecam fc = Modules.get(Freecam.class);
467
        if (fc != null && fc.isEnabled() && fc.isCameraInput()) {
468
            LocalPlayer self = (LocalPlayer) (Object) this;
469
            if (self.getAbilities().flying) return false;
470
        }
471
        return in.shift();
472
    }
473
474
    @Inject(method = "hurtTo", at = @At("HEAD"))
475
    private void freecam$onUpdateHealth(float newHealth, CallbackInfo ci) {
476
        Freecam fc = Modules.get(Freecam.class);
477
478
        if (fc == null || !fc.isEnabled() || !fc.disableOnDamage()) {
479
            freecam$lastHealth = newHealth;
480
            return;
481
        }
482
483
        if (!Float.isNaN(freecam$lastHealth) && newHealth < freecam$lastHealth) {
484
            fc.toggle();
485
        }
486
487
        freecam$lastHealth = newHealth;
488
    }
489
490
    @Unique
491
    private boolean shouldFreezeNow() {
492
        boolean freezeModule = Modules.enabled(Freeze.class);
493
        Freecam freecam = Modules.get(Freecam.class);
494
        boolean freecamFreeze = freecam != null && freecam.freezePlayer() && freecam.isCameraInput();
495
        return freezeModule || freecamFreeze;
496
    }
497
498
    @Inject(method = "sendPosition", at = @At("HEAD"), cancellable = true)
499
    private void combatant$eventSync(CallbackInfo ci) {
500
        if (!Events.BUS.hasListeners(EventSync.class)) return;
501
        combatant$eventPostAction = null;
502
        LocalPlayer self = (LocalPlayer) (Object) this;
503
        EventSync event = new EventSync(self.getYRot(), self.getXRot());
504
        Events.BUS.post(event);
505
        combatant$activeSyncEvent = event;
506
        combatant$eventPostAction = event.getPostAction();
507
        if (event.isCancelled()) {
508
            combatant$activeSyncEvent = null;
509
            combatant$eventPostAction = null;
510
            ci.cancel();
511
        }
512
    }
513
514
    @Inject(method = "sendPosition", at = @At("RETURN"))
515
    private void combatant$eventPostSync(CallbackInfo ci) {
516
        if (Events.BUS.hasListeners(EventPostSync.class)) {
517
            Events.BUS.post(new EventPostSync());
518
        }
519
        if (combatant$eventPostAction != null) {
520
            combatant$eventPostAction.run();
521
            combatant$eventPostAction = null;
522
        }
523
        combatant$activeSyncEvent = null;
524
    }
525
526
    @ModifyExpressionValue(
527
            method = "sendPosition",
528
            at = @At(
529
                    value = "INVOKE",
530
                    target = "Lnet/minecraft/client/player/LocalPlayer;getYRot()F"
531
            )
532
    )
533
    private float combatant$eventSyncYaw(float original) {
534
        combatant$updateVisualBodyYaw();
535
536
        EventSync event = combatant$activeSyncEvent;
537
        if (event != null && event.hasRotationOverride()) return event.getYaw();
538
539
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
540
        return rotation != null ? rotation.yaw() : original;
541
    }
542
543
    @ModifyExpressionValue(
544
            method = "sendPosition",
545
            at = @At(
546
                    value = "INVOKE",
547
                    target = "Lnet/minecraft/client/player/LocalPlayer;getXRot()F"
548
            )
549
    )
550
    private float combatant$eventSyncPitch(float original) {
551
        EventSync event = combatant$activeSyncEvent;
552
        if (event != null && event.hasRotationOverride()) return Mth.clamp(event.getPitch(), -90.0f, 90.0f);
553
554
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
555
        return rotation != null ? Mth.clamp(rotation.pitch(), -90.0f, 90.0f) : original;
556
    }
557
558
    @ModifyExpressionValue(
559
            method = "tick",
560
            at = @At(
561
                    value = "INVOKE",
562
                    target = "Lnet/minecraft/client/player/LocalPlayer;getYRot()F"
563
            )
564
    )
565
    private float combatant$visualTickYaw(float original) {
566
        combatant$updateVisualBodyYaw();
567
568
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
569
        return rotation != null ? rotation.yaw() : original;
570
    }
571
572
    @ModifyExpressionValue(
573
            method = "tick",
574
            at = @At(
575
                    value = "INVOKE",
576
                    target = "Lnet/minecraft/client/player/LocalPlayer;getXRot()F"
577
            )
578
    )
579
    private float combatant$visualTickPitch(float original) {
580
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
581
        return rotation != null ? Mth.clamp(rotation.pitch(), -90.0f, 90.0f) : original;
582
    }
583
584
    @Inject(
585
            method = "tick",
586
            at = @At(
587
                    value = "INVOKE",
588
                    target = "Lnet/minecraft/client/player/LocalPlayer;sendPosition()V",
589
                    ordinal = 0,
590
                    shift = At.Shift.AFTER
591
            ),
592
            cancellable = true
593
    )
594
    private void combatant$postPlayerUpdate(CallbackInfo ci) {
595
        if (!Events.BUS.hasListeners(PostPlayerUpdateEvent.class)) return;
596
        if (combatant$postUpdateLock) return;
597
598
        PostPlayerUpdateEvent event = new PostPlayerUpdateEvent();
599
        Events.BUS.post(event);
600
601
        if (!event.isCancelled()) return;
602
603
        ci.cancel();
604
605
        int iterations = event.getIterations();
606
        if (iterations <= 0) return;
607
608
        LocalPlayer self = (LocalPlayer) (Object) this;
609
        for (int i = 0; i < iterations; i++) {
610
            combatant$postUpdateLock = true;
611
            self.tick();
612
            combatant$postUpdateLock = false;
613
            sendPosition();
614
        }
615
    }
616
617
    @Inject(method = "sendPosition", at = @At("HEAD"), cancellable = true)
618
    private void cancelPackets(CallbackInfo ci) {
619
        if (Modules.enabled(Freeze.class)) {
620
            ci.cancel();
621
        }
622
    }
623
624
    @Inject(method = "aiStep", at = @At("HEAD"), cancellable = true)
625
    private void combatant$freezeTickMovement(CallbackInfo ci) {
626
        LocalPlayer p = (LocalPlayer) (Object) this;
627
628
        if (!shouldFreezeNow()) {
629
            if (frozen) {
630
                p.setDeltaMovement(savedVelocity);
631
                frozen = false;
632
            }
633
            return;
634
        }
635
636
        if (!frozen) {
637
            frozen = true;
638
            savedX = p.getX();
639
            savedY = p.getY();
640
            savedZ = p.getZ();
641
            savedVelocity = p.getDeltaMovement();
642
643
            if (Modules.get(Freecam.class) == null || !Modules.get(Freecam.class).isEnabled()) {
644
                savedBodyYaw = p.yBodyRot;
645
                savedHeadYaw = p.yHeadRot;
646
            }
647
        }
648
649
        p.setDeltaMovement(Vec3.ZERO);
650
        p.absSnapTo(savedX, savedY, savedZ);
651
652
        if (Modules.get(Freecam.class) == null || !Modules.get(Freecam.class).isEnabled()) {
653
            p.yBodyRot = savedBodyYaw;
654
            p.yHeadRot = savedHeadYaw;
655
        }
656
657
        ci.cancel();
658
    }
659
660
    @Inject(method = "aiStep", at = @At("HEAD"))
661
    private void combatant$noStunTickMovement(CallbackInfo ci) {
662
        NoStun ns = Modules.get(NoStun.class);
663
        if (ns == null || !ns.isEnabled()) return;
664
665
        Freecam fc = Modules.get(Freecam.class);
666
        if (fc != null && fc.isEnabled() && fc.isCameraInput()) {
667
            return;
668
        }
669
670
        LocalPlayer player = (LocalPlayer) (Object) this;
671
        if (ns.isFunctionEnabled(NoStun.fnNoHurtStun())) {
672
            if (player.hurtTime == 0) {
673
                lastInput = player.input.keyPresses;
674
            } else if (lastInput != null) {
675
                player.input.keyPresses = lastInput;
676
            }
677
        }
678
679
    }
680
681
    @Unique
682
    private void combatant$updateVisualBodyYaw() {
683
        LocalPlayer self = (LocalPlayer) (Object) this;
684
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
685
        if (rotation == null) {
686
            combatant$rotationPrevX = self.getX();
687
            combatant$rotationPrevZ = self.getZ();
688
            combatant$rotationPrevBodyYaw = self.getVisualRotationYInDegrees();
689
            return;
690
        }
691
692
        float newBodyYaw = combatant$simulateBodyYaw(
693
                rotation.yaw(),
694
                combatant$rotationPrevBodyYaw,
695
                combatant$rotationPrevX,
696
                combatant$rotationPrevZ,
697
                self.getX(),
698
                self.getZ(),
699
                self.attackAnim
700
        );
701
702
        self.setYBodyRot(newBodyYaw);
703
        combatant$rotationPrevBodyYaw = newBodyYaw;
704
        combatant$rotationPrevX = self.getX();
705
        combatant$rotationPrevZ = self.getZ();
706
    }
707
708
    @Inject(method = "tick", at = @At("HEAD"))
709
    private void detectPearlImpact(CallbackInfo ci) {
710
        NoPush noPush = Modules.get(NoPush.class);
711
        if (noPush == null || !noPush.off("pearl_phase"))
712
            return;
713
714
        LocalPlayer p = (LocalPlayer) (Object) this;
715
716
        List<ThrownEnderpearl> pearls = new ArrayList<>();
717
        p.level().getEntities(
718
                EntityTypeTest.forClass(ThrownEnderpearl.class),
719
                p.getBoundingBox().inflate(1.5),
720
                e -> true,
721
                pearls
722
        );
723
724
        // перл соприкасается → сейчас будет телепорт → готовим спуф
725
        if (!pearls.isEmpty()) {
726
            pendingSpoof = true;
727
        }
728
    }
729
730
    @Inject(method = "sendPosition", at = @At("HEAD"))
731
    private void sendSpoofAfterPearl(CallbackInfo ci) {
732
        NoPush noPush = Modules.get(NoPush.class);
733
        if (noPush == null || !noPush.off("pearl_phase"))
734
            return;
735
736
        if (!pendingSpoof) return;
737
        LocalPlayer p = (LocalPlayer) (Object) this;
738
        // Avoid spoof on ceiling-only collision; it can freeze upward movement.
739
        if (p.verticalCollision && !p.horizontalCollision) {
740
            pendingSpoof = false;
741
            return;
742
        }
743
        pendingSpoof = false;
744
745
        Vec3 pos = p.position();
746
747
        p.connection.send(new ServerboundMovePlayerPacket.Pos(
748
                pos.x,
749
                pos.y + 0.0313, // легитная фаза
750
                pos.z,
751
                p.onGround(),
752
                false   // horizontalCollision
753
        ));
754
    }
755
756
    @Inject(method = "aiStep", at = @At("TAIL"))
757
    private void onCollideBoost(CallbackInfo ci) {
758
759
        Speed speed = Modules.get(Speed.class);
760
        if (speed == null || !speed.enabled("entity_boost"))
761
            return;
762
763
        LocalPlayer p = (LocalPlayer) (Object) this;
764
765
        if (boostTicks > 0) {
766
            boostTicks--;
767
768
            Vec3 vel = p.getDeltaMovement();
769
            double vx = vel.x + boostX;
770
            double vz = vel.z + boostZ;
771
772
            double max = 0.48;
773
            double h = Math.hypot(vx, vz);
774
            if (h > max) {
775
                double s = max / h;
776
                vx *= s;
777
                vz *= s;
778
            }
779
780
            p.setDeltaMovement(vx, vel.y, vz);
781
            return;
782
        }
783
784
        List<Entity> nearby = p.level().getEntities(p, p.getBoundingBox().inflate(0.15), e -> e instanceof LivingEntity);
785
        if (nearby.isEmpty()) return;
786
787
        Vec3 vel = p.getDeltaMovement();
788
        double dirX = vel.x;
789
        double dirZ = vel.z;
790
791
        if (dirX == 0 && dirZ == 0) return;
792
793
        double len = Math.sqrt(dirX * dirX + dirZ * dirZ);
794
        if (len < 1e-5) return;
795
796
        dirX /= len;
797
        dirZ /= len;
798
799
        double boost = speed.entityBoostStrength.get();
800
801
        boostX = (dirX * boost) / 3.0;
802
        boostZ = (dirZ * boost) / 3.0;
803
        boostTicks = 3;
804
    }
805
806
    @Inject(method = "aiStep", at = @At("TAIL"))
807
    private void omniLongJump(CallbackInfo ci) {
808
        Speed speed = Modules.get(Speed.class);
809
        if (speed == null || !speed.enabled("jump_boost")) return;
810
        LocalPlayer p = (LocalPlayer) (Object) this;
811
812
        boolean onGround = p.onGround();
813
814
        if (p.isFallFlying()) {
815
            wasGround = onGround;
816
            return;
817
        }
818
819
        if (wasGround && !onGround && p.isSprinting() && !p.isInWater()) {
820
821
            Vec2 move = p.input.getMoveVector();
822
            float mx = move.x;
823
            float mz = move.y;
824
825
            if (mx == 0 && mz == 0) {
826
                wasGround = onGround;
827
                return;
828
            }
829
830
            float norm = Mth.sqrt(mx * mx + mz * mz);
831
            mx /= norm;
832
            mz /= norm;
833
834
            float yaw = p.getYRot();
835
            float rad = (float) Math.toRadians(yaw);
836
837
            double dirX = mz * -Mth.sin(rad) + mx * Mth.cos(rad);
838
            double dirZ = mz * Mth.cos(rad) + mx * Mth.sin(rad);
839
840
            Vec3 vel = p.getDeltaMovement();
841
            double ui = speed.jumpAcceleration.get();
842
            double internal = ui * 0.832;
843
            double strength = 0.33 * internal;
844
845
            double vx = dirX * strength;
846
            double vz = dirZ * strength;
847
            double max = 0.42;
848
            double h = Math.hypot(vx, vz);
849
850
            if (h > max) {
851
                double scale = max / h;
852
                vx *= scale;
853
                vz *= scale;
854
            }
855
856
            p.setDeltaMovement(vx, vel.y, vz);
857
        }
858
859
        wasGround = onGround;
860
    }
861
862
    @Inject(method = "modifyInput", at = @At("RETURN"), cancellable = true)
863
    private void applyLegitSpeed(Vec2 input, CallbackInfoReturnable<Vec2> cir) {
864
        Speed speed = Modules.get(Speed.class);
865
        if (speed == null || !speed.isEnabled()) return;
866
        if (!speed.enabled("legit_speed")) return;
867
        Vec2 base = cir.getReturnValue();
868
        float mult = speed.legitMultiplier.get();
869
        cir.setReturnValue(base.scale(mult));
870
    }
871
872
    @Inject(method = "closeContainer", at = @At("HEAD"), cancellable = true)
873
    private void combatant$inventoryMove$deferCloseHandledScreen(CallbackInfo ci) {
874
        InventoryMove module = Modules.get(InventoryMove.class);
875
        if (module == null || !module.isEnabled()) return;
876
        if (module.shouldCancelCloseHandledScreen()) {
877
            ci.cancel();
878
        }
879
    }
880
881
    @Inject(method = "closeContainer", at = @At("HEAD"), cancellable = true)
882
    private void combatant$keepInventoryOpen(CallbackInfo ci) {
883
        if (!Modules.enabled(XCarry.class)) return;
884
885
        // Cancel only when closing own inventory screen (PlayerScreenHandler) to retain crafting/cursor items
886
        var screen = ClientScreen.current(net.minecraft.client.Minecraft.getInstance());
887
        if (screen instanceof net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<?> handled
888
                && handled.getMenu() instanceof InventoryMenu) {
889
            ((LocalPlayer) (Object) this).clientSideCloseContainer(); // client-side close without sending packet
890
            ci.cancel(); // skip packet CloseHandledScreen
891
        }
892
    }
893
894
    @Inject(method = "moveTowardsClosestSpace", at = @At("HEAD"), cancellable = true)
895
    private void combatant$noPushOutOfBlocks(double x, double z, CallbackInfo ci) {
896
        if (!Events.BUS.hasListeners(EventPushOutOfBlocks.class)) return;
897
        EventPushOutOfBlocks event = new EventPushOutOfBlocks(x, z);
898
        Events.BUS.post(event);
899
        if (event.isCancelled()) {
900
            ci.cancel();
901
        }
902
    }
903
}
904
LocatorBarMixinsrc/main/java/combatant/client/mixins/LocatorBarMixin.javaJava · 53 lines · 1.9 KB
@Mixin(LocatorBar.class)
ModifiesLocatorBar
LocatorBarMixin.javaJava · 53 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.DeltaTracker;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.contextualbar.LocatorBar;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.gui.hud.nondraggable.impl.CustomBar;
19
import combatant.client.runtime.RuntimeGate;
20
21
@Mixin(LocatorBar.class)
22
public abstract class LocatorBarMixin {
23
24
    @Inject(method = "extractBackground", at = @At("HEAD"), cancellable = true)
25
    private void combatant$renderLocatorBar(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
26
        if (!RuntimeGate.canRunHud()) return;
27
        Minecraft mc = Minecraft.getInstance();
28
        if (mc == null || mc.player == null) return;
29
30
        CustomBar bar = CustomBar.get();
31
        if (bar == null) return;
32
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
33
34
        // Suppress vanilla locator rendering; Combatant owns the locator pass.
35
        ci.cancel();
36
    }
37
38
    @Inject(method = "extractRenderState", at = @At("HEAD"), cancellable = true)
39
    private void combatant$renderLocatorAddons(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
40
        if (!RuntimeGate.canRunHud()) return;
41
        Minecraft mc = Minecraft.getInstance();
42
        if (mc == null || mc.player == null) return;
43
44
        CustomBar bar = CustomBar.get();
45
        if (bar == null) return;
46
        if (!bar.isHudBarEnabled() || !bar.isHotbarXpBarEnabled()) return;
47
48
        // Always mute vanilla locator addons (markers/arrows).
49
        ci.cancel();
50
    }
51
}
52
53
MinecraftMixinsrc/main/java/combatant/client/mixins/MinecraftMixin.javaJava · 441 lines · 16.3 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
MinecraftMixin.javaJava · 441 lines · 16.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.systems.GpuSurface;
11
import combatant.client.features.module.modules.combat.*;
12
import net.minecraft.client.FramerateLimiter;
13
import net.minecraft.client.Minecraft;
14
import net.minecraft.client.main.GameConfig;
15
import net.minecraft.client.multiplayer.ClientLevel;
16
import net.minecraft.client.player.LocalPlayer;
17
import net.minecraft.core.BlockPos;
18
import net.minecraft.core.Direction;
19
import net.minecraft.util.Mth;
20
import net.minecraft.world.entity.Entity;
21
import net.minecraft.world.entity.LivingEntity;
22
import net.minecraft.world.entity.player.Player;
23
import net.minecraft.world.item.ItemStack;
24
import net.minecraft.world.phys.BlockHitResult;
25
import net.minecraft.world.phys.EntityHitResult;
26
import net.minecraft.world.phys.Vec3;
27
import org.spongepowered.asm.mixin.Final;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
35
import combatant.client.events.Events;
36
import combatant.client.events.impl.CrosshairTargetUpdateEvent;
37
import combatant.client.features.gui.chat.BetterChatStoreManager;
38
import combatant.client.features.module.ModuleManager;
39
import combatant.client.features.module.Modules;
40
import combatant.client.features.module.modules.movement.Timer;
41
import combatant.client.features.module.modules.player.NoDelay;
42
import combatant.client.features.module.modules.player.NoInteract;
43
import combatant.client.features.module.modules.visuals.Freecam;
44
import combatant.client.features.module.modules.visuals.ViewModel;
45
import combatant.client.features.relations.StaffTracker;
46
import combatant.client.render.helpers.TickDelta;
47
import combatant.client.render.helpers.PlayerHeadRenderer;
48
import combatant.client.util.player.PlayerSkinResolver;
49
import combatant.client.util.combat.AntiBotTracker;
50
import combatant.client.util.session.SessionChanger;
51
import combatant.client.util.session.MinecraftGameConfigHolder;
52
53
@Mixin(Minecraft.class)
54
public class MinecraftMixin implements MinecraftGameConfigHolder {
55
56
    @Shadow
57
    @Final
58
    private GpuSurface windowSurface;
59
60
    @Unique
61
    private GameConfig combatant$gameConfig;
62
63
    @Inject(method = "<init>", at = @At("RETURN"))
64
    private void combatant$captureGameConfig(GameConfig config, CallbackInfo ci) {
65
        this.combatant$gameConfig = config;
66
    }
67
68
    @Override
69
    public GameConfig combatant$getGameConfig() {
70
        return combatant$gameConfig;
71
    }
72
73
    @Unique
74
    private static BlockHitResult combatant$miss(Vec3 pos) {
75
        return new BlockHitResult(
76
                pos,
77
                Direction.UP,
78
                BlockPos.ZERO,
79
                false
80
        );
81
    }
82
83
    @Unique
84
    private static void combatant$guardSingleplayerSaveWithAltUsername() {
85
        SessionChanger.restoreSingleplayerJoinSessionForDisconnect();
86
    }
87
88
    @Inject(method = "startUseItem", at = @At("HEAD"), cancellable = true)
89
    private void fastThrow(CallbackInfo ci) {
90
        NoDelay noDelay = Modules.get(NoDelay.class);
91
        if (noDelay != null && noDelay.handleFastUse()) {
92
            ci.cancel();
93
            return;
94
        }
95
96
        AutoBow autoBow = Modules.get(AutoBow.class);
97
        if (autoBow != null && autoBow.shouldCancelVanillaDoItemUse()) {
98
            ci.cancel();
99
        }
100
    }
101
102
    @Inject(
103
            method = "handleKeybinds",
104
            at = @At("HEAD")
105
    )
106
    private void spearassist$blockAttackInput(CallbackInfo ci) {
107
        Minecraft mc = Minecraft.getInstance();
108
        if (mc.player == null) return;
109
110
        SpearAssist assist = Modules.get(SpearAssist.class);
111
        if (assist == null || !assist.isEnabled() || !assist.respectCooldownEnabled()) {
112
            return;
113
        }
114
115
        ItemStack stack = mc.player.getMainHandItem();
116
        if (!SpearAssist.isSpear(stack)) return;
117
118
        float cooldown = mc.player.getAttackStrengthScale(0.0F);
119
        if (cooldown < 0.99F) {
120
            // ВАЖНО: гасим сам ввод
121
            mc.options.keyAttack.setDown(false);
122
        }
123
    }
124
125
    @Inject(method = "handleKeybinds", at = @At("TAIL"))
126
    private void combatant$autobow$finishInputCycle(CallbackInfo ci) {
127
        AutoBow autoBow = Modules.get(AutoBow.class);
128
        if (autoBow != null && autoBow.isEnabled()) {
129
            autoBow.onInputCycleHandled();
130
        }
131
    }
132
133
    @Inject(method = "shouldEntityAppearGlowing", at = @At("HEAD"), cancellable = true)
134
    private void combatant$disablePvpGlow(Entity entity, CallbackInfoReturnable<Boolean> cir) {
135
        if (!(entity instanceof Player)) return;
136
        PvpCooldowns mod = Modules.get(PvpCooldowns.class);
137
        if (mod == null || !mod.shouldHideTargetGlow()) return;
138
        cir.setReturnValue(false);
139
    }
140
141
142
    // === КУРСОР ДЛЯ CLICKGUI ===
143
144
    @Inject(method = "continueAttack", at = @At("HEAD"), cancellable = true)
145
    private void onHandleBlockBreaking(boolean breaking, CallbackInfo ci) {
146
        Minecraft client = Minecraft.getInstance();
147
        LocalPlayer player = client.player;
148
        if (player == null) return;
149
150
        // Hitbox должен работать даже при ломании блоков: не блокируем vanilla логику
151
        Hitbox hitbox = Modules.get(Hitbox.class);
152
        if (hitbox != null && hitbox.isEnabled()) {
153
            return;
154
        }
155
156
        boolean attackKeyPressed = client.options.keyAttack.isDown();
157
158
        AutoAttack autoAttack = Modules.get(AutoAttack.class);
159
        boolean blockByAutoAttack = autoAttack != null
160
                && autoAttack.isEnabled()
161
                && !autoAttack.isAutoMode()
162
                && autoAttack.shouldBlockBreaking();
163
        boolean shouldBlockBreaking = blockByAutoAttack;
164
165
        if (shouldBlockBreaking && attackKeyPressed) {
166
167
            // блокируем ломание
168
            ci.cancel();
169
170
            if (client.gameMode != null)
171
                client.gameMode.stopDestroyBlock();
172
173
            // имитация удара
174
        }
175
    }
176
177
    @Inject(method = "startAttack", at = @At("HEAD"), cancellable = true)
178
    private void onDoAttack(CallbackInfoReturnable<Boolean> cir) {
179
        AttributeSwap attributeSwap = Modules.get(AttributeSwap.class);
180
        if (attributeSwap != null && attributeSwap.isEnabled() && attributeSwap.handleManualAttack()) {
181
            cir.setReturnValue(true);
182
            cir.cancel();
183
            return;
184
        }
185
186
        AutoAttack autoAttack = Modules.get(AutoAttack.class);
187
        if (autoAttack != null && autoAttack.isEnabled()) {
188
            cir.setReturnValue(false);
189
            cir.cancel();
190
        }
191
    }
192
193
    @Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;ZZ)V", at = @At("HEAD"))
194
    private void combatant$betterChat$saveOnDisconnect(net.minecraft.client.gui.screens.Screen screen, boolean transferring, boolean bl, CallbackInfo ci) {
195
        combatant$guardSingleplayerSaveWithAltUsername();
196
        if (!transferring) {
197
            PlayerHeadRenderer.clearSessionCache();
198
            PlayerSkinResolver.clearAll();
199
        }
200
        try {
201
            BetterChatStoreManager.flushAll();
202
        } catch (Throwable ignored) {
203
        }
204
    }
205
206
    @Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;ZZ)V", at = @At("TAIL"))
207
    private void combatant$sessionRestoreAfterDisconnect(net.minecraft.client.gui.screens.Screen screen, boolean transferring, boolean bl, CallbackInfo ci) {
208
        SessionChanger.restoreDeferredSessionAfterDisconnect();
209
    }
210
211
    @Inject(method = "pick", at = @At("HEAD"), cancellable = true)
212
    private void onUpdateCrosshairTarget(float tickDelta, CallbackInfo ci) {
213
        Minecraft mc = Minecraft.getInstance();
214
        if (mc.player == null || mc.level == null) return;
215
216
        var fc = Modules.get(Freecam.class);
217
218
        // =========================================================
219
        // FREECAM
220
        // =========================================================
221
        if (fc != null && fc.isEnabled()) {
222
223
            // позиция и направление FREECAM
224
            Vec3 start = new Vec3(
225
                    Mth.lerp(tickDelta, fc.camPosPrev.x, fc.camPos.x),
226
                    Mth.lerp(tickDelta, fc.camPosPrev.y, fc.camPos.y),
227
                    Mth.lerp(tickDelta, fc.camPosPrev.z, fc.camPos.z)
228
            );
229
230
            float yawRad = -fc.camYaw * ((float) Math.PI / 180F);
231
            float pitchRad = -fc.camPitch * ((float) Math.PI / 180F);
232
233
            Vec3 dir = new Vec3(
234
                    Mth.sin(yawRad) * Mth.cos(pitchRad),
235
                    Mth.sin(pitchRad),
236
                    Mth.cos(yawRad) * Mth.cos(pitchRad)
237
            );
238
239
            // ===============================
240
            // FREECAM + NO INTERACT
241
            // ===============================
242
            if (!fc.allowInteract()) {
243
                mc.hitResult = combatant$miss(start);
244
                mc.crosshairPickEntity = null;
245
                ci.cancel();
246
                return;
247
            }
248
249
            // ===============================
250
            // FREECAM + INTERACT
251
            // ===============================
252
253
            // Reach (FREECAM)
254
            Reach reachModule = Modules.get(Reach.class);
255
            if (reachModule != null && reachModule.isEnabled()) {
256
                EntityHitResult hit = reachModule.raycastEntities(
257
                        mc.player, start, dir
258
                );
259
260
                if (hit != null && hit.getEntity() instanceof LivingEntity target && target.isAlive()) {
261
                    mc.hitResult = hit;
262
                    mc.crosshairPickEntity = target;
263
                    ci.cancel();
264
                    return;
265
                }
266
            }
267
268
            // Blocks (FREECAM)
269
            double reach = mc.player.blockInteractionRange();
270
            Vec3 end = start.add(dir.scale(reach));
271
272
            BlockHitResult bhr = mc.level.clip(new net.minecraft.world.level.ClipContext(
273
                    start, end,
274
                    net.minecraft.world.level.ClipContext.Block.OUTLINE,
275
                    net.minecraft.world.level.ClipContext.Fluid.NONE,
276
                    mc.player
277
            ));
278
279
            mc.hitResult = bhr;
280
            mc.crosshairPickEntity = null;
281
            ci.cancel();
282
            return;
283
        }
284
285
        Reach reachModule = Modules.get(Reach.class);
286
        if (reachModule != null && reachModule.isEnabled()) {
287
            EntityHitResult entityHit = reachModule.raycastEntities(mc.player);
288
            if (entityHit != null && entityHit.getEntity() instanceof LivingEntity target && target.isAlive()) {
289
                mc.hitResult = entityHit;
290
                mc.crosshairPickEntity = target;
291
                ci.cancel();
292
            }
293
        }
294
    }
295
296
    @Inject(method = "pick", at = @At("RETURN"))
297
    private void combatant$dispatchCrosshairTargetEvent(float tickDelta, CallbackInfo ci) {
298
        Minecraft mc = Minecraft.getInstance();
299
        if (mc.player == null || mc.level == null) return;
300
301
        CrosshairTargetUpdateEvent event = new CrosshairTargetUpdateEvent(
302
                tickDelta,
303
                mc.hitResult,
304
                mc.crosshairPickEntity
305
        );
306
        Events.BUS.post(event);
307
        mc.hitResult = event.getHitResult();
308
        mc.crosshairPickEntity = event.getTargetedEntity();
309
    }
310
311
    @Inject(method = "pick", at = @At("RETURN"))
312
    private void noInteract$afterRaycast(float tickDelta, CallbackInfo ci) {
313
        Minecraft mc = Minecraft.getInstance();
314
        if (mc.player == null || mc.level == null) return;
315
316
        NoInteract noInteract = Modules.get(NoInteract.class);
317
        if (noInteract == null || !noInteract.shouldBlockBlockInteraction()) return;
318
319
        var hit = mc.hitResult;
320
        if (hit instanceof EntityHitResult) return;
321
322
        Vec3 camPos = mc.player.getEyePosition(tickDelta);
323
        mc.hitResult = new BlockHitResult(
324
                camPos,
325
                Direction.UP,
326
                BlockPos.ZERO,
327
                false
328
        );
329
        mc.crosshairPickEntity = null;
330
    }
331
332
    @Inject(method = "disconnect", at = @At("HEAD"))
333
    private void freecam$onDisconnect(CallbackInfo ci) {
334
        Freecam fc = Modules.get(Freecam.class);
335
        if (fc != null && fc.isEnabled()) {
336
            fc.toggle();
337
        }
338
    }
339
340
    @Inject(method = "setLevel", at = @At("HEAD"))
341
    private void freecam$onJoinWorld(ClientLevel world, CallbackInfo ci) {
342
        Freecam fc = Modules.get(Freecam.class);
343
        if (fc != null && fc.isEnabled()) {
344
            fc.toggle();
345
        }
346
    }
347
348
    @Inject(method = "setLevel", at = @At("TAIL"))
349
    private void combatant$captureSingleplayerJoinSession(ClientLevel world, CallbackInfo ci) {
350
        if (world == null) {
351
            SessionChanger.clearSingleplayerJoinSession();
352
        } else {
353
            SessionChanger.captureSingleplayerJoinSession();
354
        }
355
    }
356
357
    @Inject(method = "clearDownloadedResourcePacks", at = @At("HEAD"))
358
    private void combatant$onDisconnected(CallbackInfo ci) {
359
        StaffTracker.resetAll();
360
        AntiBotTracker.INSTANCE.reset();
361
    }
362
363
    @Inject(
364
            method = "renderFrame",
365
            at = @At(
366
                    value = "INVOKE",
367
                    target = "Lnet/minecraft/client/DeltaTracker$Timer;advanceRealTime(J)V",
368
                    shift = At.Shift.AFTER
369
            )
370
    )
371
    private void combatant$frameModulesAfterRenderTick(boolean tick, CallbackInfo ci) {
372
        ModuleManager.frameAll(TickDelta.frameDeltaTicks());
373
    }
374
375
    @Inject(
376
            method = "renderFrame",
377
            at = @At(
378
                    value = "INVOKE_STRING",
379
                    target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V",
380
                    args = "ldc=frameLimiter",
381
                    shift = At.Shift.AFTER
382
            )
383
    )
384
    private void combatant$paceImmediateNoVsync(boolean tick, CallbackInfo ci) {
385
        Minecraft mc = (Minecraft) (Object) this;
386
        if (mc == null || mc.options == null || mc.getWindow() == null || windowSurface == null) {
387
            return;
388
        }
389
        if (Boolean.TRUE.equals(mc.options.enableVsync().get())) {
390
            return;
391
        }
392
        if (windowSurface.currentConfiguration().isEmpty()
393
                || windowSurface.currentConfiguration().get().presentMode() != GpuSurface.PresentMode.IMMEDIATE) {
394
            return;
395
        }
396
397
        int configuredLimit = mc.gameRenderer.gameRenderState().framerateLimit;
398
        if (configuredLimit < 260) {
399
            return;
400
        }
401
402
        int refreshRate = mc.getWindow().getRefreshRate();
403
        int targetFps = combatant$immediatePacingTarget(refreshRate);
404
        FramerateLimiter.limitDisplayFPS(targetFps);
405
    }
406
407
    @Unique
408
    private static int combatant$immediatePacingTarget(int refreshRate) {
409
        int base = refreshRate > 0 ? refreshRate : 120;
410
        return Mth.clamp(base * 2, 120, 360);
411
    }
412
413
    @Inject(method = "getTickTargetMillis", at = @At("RETURN"), cancellable = true)
414
    private void combatant$applyTimer(float millis, CallbackInfoReturnable<Float> cir) {
415
        float mult = Timer.getTickTimer();
416
        if (mult <= 0.0001f) return;
417
        if (Math.abs(mult - 1.0f) < 0.0001f) return;
418
        float base = cir.getReturnValue();
419
        cir.setReturnValue(base / mult);
420
    }
421
422
    @Inject(method = "isLevelRunningNormally", at = @At("HEAD"), cancellable = true)
423
    private void combatant$skipPlayerDependentTicksWithoutPlayer(CallbackInfoReturnable<Boolean> cir) {
424
        Minecraft mc = Minecraft.getInstance();
425
        if (mc.level != null && mc.player == null) {
426
            cir.setReturnValue(false);
427
        }
428
    }
429
    @Inject(method = "reloadResourcePacks()Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
430
    private void combatant$viewModel$resourceReload(CallbackInfoReturnable<java.util.concurrent.CompletableFuture<Void>> cir) {
431
        java.util.concurrent.CompletableFuture<Void> future = cir.getReturnValue();
432
        if (future == null) return;
433
434
        future.thenRun(() -> Minecraft.getInstance().execute(() -> {
435
            ViewModel viewModel = Modules.get(ViewModel.class);
436
            if (viewModel != null) viewModel.onHmiResourceReload();
437
        }));
438
    }
439
440
}
441
MouseMixinsrc/main/java/combatant/client/mixins/MouseMixin.javaJava · 225 lines · 8.7 KB
@Mixin(MouseHandler.class)
ModifiesMouseHandler
MouseMixin.javaJava · 225 lines · 8.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import combatant.client.features.gui.mainmenu.CombatantProxyManagerScreen;
12
import combatant.client.util.screen.ClientScreen;
13
import net.minecraft.client.Minecraft;
14
import net.minecraft.client.MouseHandler;
15
import net.minecraft.client.input.MouseButtonInfo;
16
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
17
import net.minecraft.client.player.LocalPlayer;
18
import net.minecraft.util.Mth;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.Unique;
21
import org.spongepowered.asm.mixin.injection.At;
22
import org.spongepowered.asm.mixin.injection.Inject;
23
import org.spongepowered.asm.mixin.injection.Redirect;
24
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25
import combatant.client.features.gui.chat.BetterChatRenderer;
26
import combatant.client.features.gui.clickgui.ClickGuiEditorScreen;
27
import combatant.client.features.gui.clickgui.ClickGuiPickerScreen;
28
import combatant.client.features.gui.clickgui.ClickGuiRenderer;
29
import combatant.client.features.gui.clickgui.ClickGuiScreen;
30
import combatant.client.features.gui.preview.VisualPreviewScreen;
31
import combatant.client.features.gui.hud.nondraggable.StaticHudElementRegistry;
32
import combatant.client.features.gui.hud.nondraggable.impl.DynamicIsland;
33
import combatant.client.features.module.ModuleManager;
34
import combatant.client.features.module.Modules;
35
import combatant.client.features.module.modules.visuals.Freecam;
36
import combatant.client.features.module.modules.visuals.Zoom;
37
import combatant.client.runtime.RuntimeGate;
38
import combatant.client.util.input.KeyManager;
39
import combatant.client.util.logging.DebugLog;
40
41
@Mixin(MouseHandler.class)
42
public class MouseMixin {
43
44
45
    @Unique
46
    private double lastX;
47
    @Unique
48
    private double lastY;
49
    @Unique
50
    private static final float COMBATANT_PROXY_BUTTON_X = 8f;
51
    @Unique
52
    private static final float COMBATANT_PROXY_BUTTON_Y = 8f;
53
    @Unique
54
    private static final float COMBATANT_PROXY_BUTTON_W = 24f;
55
    @Unique
56
    private static final float COMBATANT_PROXY_BUTTON_H = 24f;
57
58
    // ===== Mouse scroll for ClickGUI =====
59
    @Inject(method = "onScroll", at = @At("HEAD"), cancellable = true)
60
    public void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
61
        Minecraft mc = Minecraft.getInstance();
62
        if (RuntimeGate.canRunClientLogic()
63
                && ModuleManager.isEnabled("clickgui")
64
                && ClientScreen.current() == null) {
65
            ClickGuiRenderer.onMouseScroll(lastX, lastY, vertical);
66
            ci.cancel();
67
            return;
68
        }
69
        if (RuntimeGate.canRunHud()
70
                && ClientScreen.current(net.minecraft.client.Minecraft.getInstance()) instanceof net.minecraft.client.gui.screens.ChatScreen) {
71
            if (BetterChatRenderer.onScroll(vertical)) {
72
                ci.cancel();
73
            }
74
        }
75
    }
76
77
    @Inject(method = "onButton", at = @At("HEAD"), cancellable = true)
78
    private void betterChat$mouseButton(long window, MouseButtonInfo input, int action, CallbackInfo ci) {
79
        KeyManager.handleMouseButtonEvent(input.button(), action);
80
81
        net.minecraft.client.Minecraft mc = net.minecraft.client.Minecraft.getInstance();
82
        if (RuntimeGate.canRunHud() && mc != null) {
83
            boolean pressed = action == 1;
84
            int button = input.button();
85
            if (pressed && button == 0 && ClientScreen.current() instanceof JoinMultiplayerScreen screen) {
86
                double scale = Math.max(1.0, mc.getWindow().getGuiScale());
87
                float mx = (float) (mc.mouseHandler.xpos() / scale);
88
                float my = (float) (mc.mouseHandler.ypos() / scale);
89
                if (combatant$proxyButtonHit(mx, my)) {
90
                    ClientScreen.show(mc, new CombatantProxyManagerScreen(screen));
91
                    ci.cancel();
92
                    return;
93
                }
94
            }
95
            if (ClientScreen.current() instanceof net.minecraft.client.gui.screens.ChatScreen) {
96
                double mx = mc.mouseHandler.xpos();
97
                double my = mc.mouseHandler.ypos();
98
                if (BetterChatRenderer.onMouseButton(mx, my, button, pressed)) {
99
                    ci.cancel();
100
                    return;
101
                }
102
            }
103
            if ((ClientScreen.current() instanceof net.minecraft.client.gui.screens.ChatScreen
104
                    || DynamicIsland.shouldRenderInScreenOverlay(ClientScreen.current()))
105
                    && StaticHudElementRegistry.handleMouseButton(button, pressed)) {
106
                ci.cancel();
107
            }
108
        }
109
    }
110
111
    @Unique
112
    private static boolean combatant$proxyButtonHit(float mx, float my) {
113
        return mx >= COMBATANT_PROXY_BUTTON_X
114
                && mx <= COMBATANT_PROXY_BUTTON_X + COMBATANT_PROXY_BUTTON_W
115
                && my >= COMBATANT_PROXY_BUTTON_Y
116
                && my <= COMBATANT_PROXY_BUTTON_Y + COMBATANT_PROXY_BUTTON_H;
117
    }
118
119
    // ===== Mouse button for ClickGUI =====
120
    @Inject(method = "onButton", at = @At("HEAD"), cancellable = true)
121
    private void clickGuiMouseButton(long window, MouseButtonInfo input, int action, CallbackInfo ci) {
122
        Minecraft mc = Minecraft.getInstance();
123
        if (RuntimeGate.canRunClientLogic()
124
                && ModuleManager.isEnabled("clickgui")
125
                && ClientScreen.current() == null) {
126
127
            // action == 1 — это "нажато" (см. оригинальный код: boolean bl = action == 1;)
128
            boolean pressed = (action == 1);
129
130
            // Кнопка теперь внутри MouseInput
131
            int button = input.button();
132
133
            DebugLog.info("[CLICK] button=%d action=%d x=%.2f y=%.2f",
134
                    button, action, lastX, lastY);
135
136
            ClickGuiRenderer.onMouseButton(lastX, lastY, button, pressed);
137
138
            ci.cancel();
139
        }
140
    }
141
142
    // ===== Mouse move for ClickGUI =====
143
    @Inject(method = "onMove", at = @At("HEAD"), cancellable = true)
144
    private void clickGuiCursorMove(long window, double x, double y, CallbackInfo ci) {
145
146
        Minecraft mc = Minecraft.getInstance();
147
148
        // Always track last mouse position
149
        lastX = x;
150
        lastY = y;
151
152
        if (RuntimeGate.canRunClientLogic()
153
                && ModuleManager.isEnabled("clickgui")
154
                && ClientScreen.current() == null) {
155
            ClickGuiRenderer.onMouseMove(x, y);
156
            ci.cancel();
157
            return;
158
        }
159
160
        if (RuntimeGate.canRunHud()
161
                && ClientScreen.current() instanceof net.minecraft.client.gui.screens.ChatScreen) {
162
            BetterChatRenderer.onMouseMove(x, y);
163
        }
164
    }
165
166
    @Redirect(
167
            method = "turnPlayer",
168
            at = @At(
169
                    value = "INVOKE",
170
                    target = "Lnet/minecraft/client/player/LocalPlayer;turn(DD)V"
171
            )
172
    )
173
    private void freecam$look(LocalPlayer player, double dx, double dy) {
174
        Freecam fc = Modules.get(Freecam.class);
175
176
        if (!RuntimeGate.canRunClientLogic() || fc == null || !fc.isEnabled()) {
177
            player.turn(dx, dy);
178
            return;
179
        }
180
181
        if (!fc.isCameraInput()) {
182
            player.turn(dx, dy);
183
            return;
184
        }
185
186
        Minecraft mc = Minecraft.getInstance();
187
188
        double sens = mc.options.sensitivity().get();
189
        double f = sens * 0.6 + 0.2;
190
        double scale = f * f * f * 8.0;
191
192
        float yawDelta = (float) (dx * scale * 0.15F);
193
        float pitchDelta = (float) (dy * scale * 0.15F);
194
195
        fc.camYaw += yawDelta;
196
        fc.camPitch += pitchDelta;
197
198
        fc.camPitch = Mth.clamp(fc.camPitch, -90.0F, 90.0F);
199
    }
200
201
    @ModifyExpressionValue(
202
            method = "turnPlayer",
203
            at = @At(
204
                    value = "INVOKE",
205
                    target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;",
206
                    ordinal = 0
207
            )
208
    )
209
    private Object combatant$zoomSensitivity(Object original) {
210
        Zoom zoom = Modules.get(Zoom.class);
211
        if (!RuntimeGate.canRunClientLogic() || zoom == null || !zoom.isEnabled() || !zoom.shouldApplyZoom())
212
            return original;
213
214
        if (!(original instanceof Double originalValue)) return original;
215
216
        float divisor = zoom.getZoomDivisor();
217
        if (divisor <= 1.0f) return original;
218
219
        float percent = zoom.getSensitivityPercent() / 100.0f;
220
        double factor = Mth.lerp(percent, 1.0f, divisor);
221
        if (factor <= 0.0001) return original;
222
        return originalValue / factor;
223
    }
224
}
225
MultiPlayerGameModeMixinsrc/main/java/combatant/client/mixins/MultiPlayerGameModeMixin.javaJava · 186 lines · 7.8 KB
@Mixin(MultiPlayerGameMode.class)
MultiPlayerGameModeMixin.javaJava · 186 lines · 7.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
13
import net.minecraft.client.player.LocalPlayer;
14
import net.minecraft.core.BlockPos;
15
import net.minecraft.world.InteractionHand;
16
import net.minecraft.world.InteractionResult;
17
import net.minecraft.world.entity.Entity;
18
import net.minecraft.world.entity.player.Player;
19
import net.minecraft.world.item.ItemStack;
20
import net.minecraft.world.phys.BlockHitResult;
21
import net.minecraft.world.phys.EntityHitResult;
22
import org.spongepowered.asm.mixin.Mixin;
23
import org.spongepowered.asm.mixin.injection.At;
24
import org.spongepowered.asm.mixin.injection.Inject;
25
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
27
import combatant.client.config.values.ItemCooldownRulesValue;
28
import combatant.client.events.Events;
29
import combatant.client.events.impl.AttackEntityEvent;
30
import combatant.client.events.impl.EventBreakBlock;
31
import combatant.client.features.gui.hud.draggable.impl.TargetHud;
32
import combatant.client.features.module.Modules;
33
import combatant.client.features.module.modules.combat.AttributeSwap;
34
import combatant.client.features.module.modules.combat.Criticals;
35
import combatant.client.features.module.modules.combat.Hitbox;
36
import combatant.client.features.module.modules.combat.PvpCooldowns;
37
import combatant.client.features.module.modules.misc.HitSounds;
38
import combatant.client.features.module.modules.visuals.Freecam;
39
import combatant.client.features.module.modules.visuals.HitEffect;
40
import combatant.client.mixins.accessors.WorldAccessor;
41
import combatant.client.util.player.inventory.InventorySwap;
42
import combatant.client.util.target.TargetManager;
43
44
@Mixin(MultiPlayerGameMode.class)
45
public class MultiPlayerGameModeMixin {
46
47
    @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
48
    private void combatant$skipTickWithoutPlayer(CallbackInfo ci) {
49
        if (Minecraft.getInstance().player == null) {
50
            ci.cancel();
51
        }
52
    }
53
54
    @Inject(method = "ensureHasSentCarriedItem", at = @At("HEAD"), cancellable = true)
55
    private void combatant$skipCarriedItemSyncWithoutPlayer(CallbackInfo ci) {
56
        if (Minecraft.getInstance().player == null) {
57
            ci.cancel();
58
        }
59
    }
60
61
    @ModifyExpressionValue(
62
            method = "ensureHasSentCarriedItem",
63
            at = @At(
64
                    value = "INVOKE",
65
                    target = "Lnet/minecraft/world/entity/player/Inventory;getSelectedSlot()I"
66
            )
67
    )
68
    private int combatant$hookSilentSelectedSlot(int original) {
69
        return InventorySwap.INSTANCE.effectiveSelectedSlot();
70
    }
71
72
    @Inject(method = "destroyBlock", at = @At("RETURN"))
73
    private void combatant$breakBlockEvent(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
74
        if (!cir.getReturnValue()) return;
75
        if (!Events.BUS.hasListeners(EventBreakBlock.class)) return;
76
        Events.BUS.post(new EventBreakBlock(pos));
77
    }
78
79
    @Inject(method = "useItem", at = @At("HEAD"), cancellable = true)
80
    private void onInteractItemHead(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
81
        ItemStack stack = player.getItemInHand(hand);
82
        if (stack.isEmpty()) return;
83
84
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
85
        if (cooldowns == null) return;
86
87
        // No hard-coded PvP item blocking here anymore. This path is opt-in and item-list based.
88
        if (cooldowns.shouldBlockItemUse(stack.getItem())) {
89
            cir.setReturnValue(InteractionResult.FAIL);
90
        }
91
    }
92
93
    @Inject(method = "useItem", at = @At("RETURN"))
94
    private void onInteractItemReturn(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
95
        InteractionResult result = cir.getReturnValue();
96
        if (!result.consumesAction()) return;
97
98
        ItemStack stack = player.getItemInHand(hand);
99
        if (stack.isEmpty()) return;
100
101
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
102
        if (cooldowns == null) return;
103
104
        cooldowns.tryStartLocalCooldown(stack.getItem(), ItemCooldownRulesValue.Trigger.INTERACT_ACCEPT);
105
    }
106
107
    @Inject(method = "useItemOn", at = @At("HEAD"))
108
    private void onInteractBlockHead(LocalPlayer player, InteractionHand hand, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
109
        // no PvP cooldown block on interactBlock
110
    }
111
112
    @Inject(method = "useItemOn", at = @At("RETURN"))
113
    private void onInteractBlockReturn(LocalPlayer player, InteractionHand hand, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
114
        // no PvP cooldown prediction on interactBlock
115
    }
116
117
    @Inject(method = "useItemOn", at = @At("HEAD"), cancellable = true)
118
    private void freecam$block(LocalPlayer player, InteractionHand hand, BlockHitResult hit,
119
                               CallbackInfoReturnable<InteractionResult> cir) {
120
        Freecam fc = Modules.get(Freecam.class);
121
        if (fc != null && fc.isEnabled() && !fc.allowInteract()) {
122
            cir.setReturnValue(InteractionResult.PASS);
123
            cir.cancel();
124
        }
125
    }
126
127
    @Inject(method = "useItem", at = @At("HEAD"), cancellable = true)
128
    private void freecam$item(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
129
        Freecam fc = Modules.get(Freecam.class);
130
        if (fc != null && fc.isEnabled() && !fc.allowInteract()) {
131
            cir.setReturnValue(InteractionResult.PASS);
132
            cir.cancel();
133
        }
134
    }
135
136
    @Inject(method = "interact", at = @At("HEAD"), cancellable = true)
137
    private void freecam$entity(Player player, Entity entity, EntityHitResult hit, InteractionHand hand,
138
                                CallbackInfoReturnable<InteractionResult> cir) {
139
        Freecam fc = Modules.get(Freecam.class);
140
        if (fc != null && fc.isEnabled() && !fc.allowInteract()) {
141
            cir.setReturnValue(InteractionResult.PASS);
142
            cir.cancel();
143
        }
144
    }
145
146
    @Inject(method = "attack(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;)V",
147
            at = @At("HEAD"))
148
    private void onAttackEntity(Player player, Entity target, CallbackInfo ci) {
149
        if (!((WorldAccessor) player.level()).combatant$isClient()) return;
150
151
        if (player instanceof LocalPlayer clientPlayer) {
152
            Criticals criticals = Modules.get(Criticals.class);
153
            if (criticals != null && criticals.isEnabled()) {
154
                criticals.beforeAttack(Minecraft.getInstance(), clientPlayer, target);
155
            }
156
        }
157
158
        if (Events.BUS.hasListeners(AttackEntityEvent.class)) {
159
            Events.BUS.post(new AttackEntityEvent(player, target));
160
        }
161
162
        Hitbox hitbox = Modules.get(Hitbox.class);
163
        if (hitbox != null) hitbox.markHit(target);
164
165
        HitSounds hitSounds = Modules.get(HitSounds.class);
166
        if (hitSounds != null) {
167
            hitSounds.handleHit(target);
168
        }
169
170
        HitEffect hitEffect = Modules.get(HitEffect.class);
171
        if (hitEffect != null) {
172
            hitEffect.handleHit(target);
173
        }
174
175
        TargetHud.notifyHit(target);
176
        TargetManager.onAttack(target);
177
    }
178
179
    @Inject(method = "attack(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;)V",
180
            at = @At("RETURN"))
181
    private void combatant$attributeSwapAfterClientAttack(Player player, Entity target, CallbackInfo ci) {
182
        if (player != Minecraft.getInstance().player) return;
183
        AttributeSwap.tryBreakShieldAfterClientAttack(target);
184
    }
185
}
186
NarratorManagerMixinsrc/main/java/combatant/client/mixins/NarratorManagerMixin.javaJava · 105 lines · 3.6 KB
@Mixin(GameNarrator.class)
ModifiesGameNarrator
NarratorManagerMixin.javaJava · 105 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.GameNarrator;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.NarratorStatus;
13
import net.minecraft.network.chat.Component;
14
import org.spongepowered.asm.mixin.Final;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Shadow;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
22
import combatant.client.util.NarratorBlocker;
23
24
@Mixin(GameNarrator.class)
25
public class NarratorManagerMixin {
26
27
    @Shadow
28
    @Final
29
    private Minecraft minecraft;
30
31
    @Inject(method = "sayChatQueued(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true)
32
    private void combatant$muteChat(Component message, CallbackInfo ci) {
33
        if (shouldMute()) {
34
            NarratorBlocker.enforce(this.minecraft);
35
            ci.cancel();
36
        }
37
    }
38
39
    @Inject(method = "saySystemChatQueued(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true)
40
    private void combatant$muteNarrator(Component message, CallbackInfo ci) {
41
        if (shouldMute()) {
42
            NarratorBlocker.enforce(this.minecraft);
43
            ci.cancel();
44
        }
45
    }
46
47
    @Inject(method = "saySystemQueued(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true)
48
    private void combatant$muteSystem(Component message, CallbackInfo ci) {
49
        if (shouldMute()) {
50
            NarratorBlocker.enforce(this.minecraft);
51
            ci.cancel();
52
        }
53
    }
54
55
    @Inject(method = "saySystemNow(Lnet/minecraft/network/chat/Component;)V", at = @At("HEAD"), cancellable = true)
56
    private void combatant$muteImmediateText(Component message, CallbackInfo ci) {
57
        if (shouldMute()) {
58
            NarratorBlocker.enforce(this.minecraft);
59
            ci.cancel();
60
        }
61
    }
62
63
    @Inject(method = "saySystemNow(Ljava/lang/String;)V", at = @At("HEAD"), cancellable = true)
64
    private void combatant$muteImmediateString(String message, CallbackInfo ci) {
65
        if (shouldMute()) {
66
            NarratorBlocker.enforce(this.minecraft);
67
            ci.cancel();
68
        }
69
    }
70
71
    @Inject(method = "narrateMessage(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true)
72
    private void combatant$muteSay(String message, boolean interrupt, CallbackInfo ci) {
73
        if (shouldMute()) {
74
            NarratorBlocker.enforce(this.minecraft);
75
            ci.cancel();
76
        }
77
    }
78
79
    @Inject(method = "updateNarratorStatus", at = @At("HEAD"), cancellable = true)
80
    private void combatant$blockToggle(NarratorStatus mode, CallbackInfo ci) {
81
        if (!shouldMute()) return;
82
        NarratorBlocker.enforce(this.minecraft);
83
        ci.cancel();
84
    }
85
86
    @Inject(method = "checkStatus", at = @At("HEAD"), cancellable = true)
87
    private void combatant$skipNarratorLibraryCheck(boolean narratorEnabled, CallbackInfo ci) {
88
        if (!shouldMute()) return;
89
        NarratorBlocker.enforce(this.minecraft);
90
        ci.cancel();
91
    }
92
93
    @Inject(method = "isActive", at = @At("HEAD"), cancellable = true)
94
    private void combatant$reportInactive(CallbackInfoReturnable<Boolean> cir) {
95
        if (!shouldMute()) return;
96
        cir.setReturnValue(false);
97
    }
98
99
    @Unique
100
    private boolean shouldMute() {
101
        return NarratorBlocker.isBlocked();
102
    }
103
}
104
105
OptionsNarratorMixinsrc/main/java/combatant/client/mixins/OptionsNarratorMixin.javaJava · 46 lines · 1.7 KB
@Mixin(Options.class)
ModifiesOptions
OptionsNarratorMixin.javaJava · 46 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.NarratorStatus;
12
import net.minecraft.client.OptionInstance;
13
import net.minecraft.client.Options;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
19
import combatant.client.util.NarratorBlocker;
20
21
import java.io.File;
22
23
@Mixin(Options.class)
24
public abstract class OptionsNarratorMixin {
25
26
    @Inject(method = "<init>(Lnet/minecraft/client/Minecraft;Ljava/io/File;)V", at = @At("RETURN"))
27
    private void combatant$enforceNarratorDefaults(Minecraft client, File optionsFile, CallbackInfo ci) {
28
        NarratorBlocker.enforce((Options) (Object) this);
29
    }
30
31
    @Inject(method = "save", at = @At("HEAD"))
32
    private void combatant$enforceNarratorBeforeWrite(CallbackInfo ci) {
33
        NarratorBlocker.enforce((Options) (Object) this);
34
    }
35
36
    @Inject(method = "narrator", at = @At("HEAD"))
37
    private void combatant$enforceNarratorGetter(CallbackInfoReturnable<OptionInstance<NarratorStatus>> cir) {
38
        NarratorBlocker.enforce((Options) (Object) this);
39
    }
40
41
    @Inject(method = "narratorHotkey", at = @At("HEAD"))
42
    private void combatant$enforceNarratorHotkeyGetter(CallbackInfoReturnable<OptionInstance<Boolean>> cir) {
43
        NarratorBlocker.enforce((Options) (Object) this);
44
    }
45
}
46
PaintingRendererMixinsrc/main/java/combatant/client/mixins/PaintingRendererMixin.javaJava · 42 lines · 1.6 KB
@Mixin(value = PaintingRenderer.class, priority = 1200)priority 1200
PaintingRendererMixin.javaJava · 42 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import combatant.client.features.module.Modules;
12
import combatant.client.features.module.modules.visuals.NoRender;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.entity.PaintingRenderer;
15
import net.minecraft.client.renderer.entity.state.PaintingRenderState;
16
import net.minecraft.client.renderer.state.level.CameraRenderState;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
@Mixin(value = PaintingRenderer.class, priority = 1200)
23
public abstract class PaintingRendererMixin {
24
    @Inject(
25
            method = "submit(Lnet/minecraft/client/renderer/entity/state/PaintingRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
26
            at = @At("HEAD"),
27
            cancellable = true
28
    )
29
    private void combatant$noRenderPainting(
30
            PaintingRenderState state,
31
            PoseStack poseStack,
32
            SubmitNodeCollector collector,
33
            CameraRenderState cameraState,
34
            CallbackInfo ci
35
    ) {
36
        NoRender noRender = Modules.get(NoRender.class);
37
        if (noRender != null && noRender.offEntity("paintings")) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
PanoramaMixinsrc/main/java/combatant/client/mixins/PanoramaMixin.javaJava · 47 lines · 1.8 KB
@Mixin(Panorama.class)
ModifiesPanorama
PanoramaMixin.javaJava · 47 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.config.MainConfig;
11
import combatant.client.features.gui.mainmenu.CombatantMainMenuScreen;
12
import combatant.client.render.engine.postprocess.MenuBackgroundRenderer;
13
import combatant.client.runtime.RuntimeGate;
14
import net.minecraft.client.Minecraft;
15
import net.minecraft.client.gui.GuiGraphicsExtractor;
16
import net.minecraft.client.renderer.Panorama;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
/** Replaces every vanilla panorama request with the configured Combatant menu background. */
23
@Mixin(Panorama.class)
24
public abstract class PanoramaMixin {
25
26
    @Inject(
27
            method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;II)V",
28
            at = @At("HEAD"),
29
            cancellable = true
30
    )
31
    private void combatant$replaceVanillaPanorama(GuiGraphicsExtractor context,
32
                                                   int width,
33
                                                   int height,
34
                                                   CallbackInfo ci) {
35
        if (!RuntimeGate.canRunRender()) return;
36
        if (CombatantMainMenuScreen.shouldUseVanillaTitleScreen()) return;
37
        if (!MainConfig.get().isCombatantMainMenuEnabled()) return;
38
39
        Minecraft mc = Minecraft.getInstance();
40
        if (mc == null) return;
41
42
        // Do not create PanoramaRenderState and do not enqueue the vanilla panorama overlay at all.
43
        MenuBackgroundRenderer.renderConfigured(mc);
44
        ci.cancel();
45
    }
46
}
47
ParticleManagerMixinsrc/main/java/combatant/client/mixins/ParticleManagerMixin.javaJava · 57 lines · 2.0 KB
@Mixin(ParticleEngine.class)
ParticleManagerMixin.javaJava · 57 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.particle.ParticleEngine;
11
import net.minecraft.client.particle.Particle;
12
import net.minecraft.core.particles.ParticleOptions;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18
import combatant.client.util.player.effect.StatusEffectHeuristics;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.visuals.NoRender;
21
import combatant.client.util.particle.ParticleClassCatalog;
22
23
@Mixin(ParticleEngine.class)
24
public class ParticleManagerMixin {
25
26
    @Inject(
27
            method = "createParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)Lnet/minecraft/client/particle/Particle;",
28
            at = @At("HEAD"),
29
            cancellable = true
30
    )
31
    private void combatant$particleCreate(
32
            ParticleOptions parameters,
33
            double x, double y, double z,
34
            double velocityX, double velocityY, double velocityZ,
35
            CallbackInfoReturnable<Particle> cir
36
    ) {
37
        StatusEffectHeuristics.handle(parameters, x, y, z);
38
39
        NoRender noRender = Modules.get(NoRender.class);
40
        if (noRender != null && noRender.offParticle("all_particles")) {
41
            cir.setReturnValue(null);
42
        }
43
    }
44
45
    @Inject(method = "add", at = @At("HEAD"), cancellable = true)
46
    private void combatant$particleAdd(Particle particle, CallbackInfo ci) {
47
        ParticleClassCatalog.observe(particle);
48
        NoRender noRender = Modules.get(NoRender.class);
49
        if (noRender != null && noRender.shouldHideParticle(particle)) {
50
            ci.cancel();
51
        }
52
    }
53
}
54
55
56
57
PauseScreenMixinsrc/main/java/combatant/client/mixins/PauseScreenMixin.javaJava · 81 lines · 2.7 KB
@Mixin(PauseScreen.class)
ModifiesPauseScreen
PauseScreenMixin.javaJava · 81 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.GuiGraphicsExtractor;
11
import net.minecraft.client.gui.components.Button;
12
import net.minecraft.client.gui.components.Tooltip;
13
import net.minecraft.client.gui.screens.PauseScreen;
14
import org.jetbrains.annotations.Nullable;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Shadow;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.features.module.Modules;
22
import combatant.client.features.module.modules.combat.PvpCooldowns;
23
24
@Mixin(PauseScreen.class)
25
public abstract class PauseScreenMixin {
26
    @Shadow
27
    @Nullable
28
    private Button disconnectButton;
29
30
    @Unique
31
    private Button combatant$lastExitButton;
32
    @Unique
33
    private boolean combatant$disconnectBlocked;
34
    @Unique
35
    private boolean combatant$previousExitActive = true;
36
37
    @Inject(method = "init", at = @At("TAIL"))
38
    private void combatant$blockDisconnectOnInit(CallbackInfo ci) {
39
        combatant$syncDisconnectButton();
40
    }
41
42
    @Inject(method = "extractRenderState", at = @At("HEAD"))
43
    private void combatant$blockDisconnectOnRender(GuiGraphicsExtractor context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) {
44
        combatant$syncDisconnectButton();
45
    }
46
47
    @Unique
48
    private void combatant$syncDisconnectButton() {
49
        Button button = disconnectButton;
50
        if (button == null) {
51
            combatant$lastExitButton = null;
52
            combatant$disconnectBlocked = false;
53
            return;
54
        }
55
56
        if (button != combatant$lastExitButton) {
57
            combatant$lastExitButton = button;
58
            combatant$disconnectBlocked = false;
59
            combatant$previousExitActive = button.active;
60
        }
61
62
        PvpCooldowns cooldowns = Modules.get(PvpCooldowns.class);
63
        boolean shouldBlock = cooldowns != null && cooldowns.shouldBlockDisconnect();
64
        if (shouldBlock) {
65
            if (!combatant$disconnectBlocked) {
66
                combatant$previousExitActive = button.active;
67
            }
68
            combatant$disconnectBlocked = true;
69
            button.active = false;
70
            button.setTooltip(Tooltip.create(cooldowns.getDisconnectBlockTooltip()));
71
            return;
72
        }
73
74
        if (combatant$disconnectBlocked) {
75
            button.active = combatant$previousExitActive;
76
            button.setTooltip(null);
77
            combatant$disconnectBlocked = false;
78
        }
79
    }
80
}
81
PistonHeadRendererMixinsrc/main/java/combatant/client/mixins/PistonHeadRendererMixin.javaJava · 42 lines · 1.7 KB
@Mixin(value = PistonHeadRenderer.class, priority = 1200)priority 1200
PistonHeadRendererMixin.javaJava · 42 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import combatant.client.features.module.Modules;
12
import combatant.client.features.module.modules.visuals.NoRender;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.blockentity.PistonHeadRenderer;
15
import net.minecraft.client.renderer.blockentity.state.PistonHeadRenderState;
16
import net.minecraft.client.renderer.state.level.CameraRenderState;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
22
@Mixin(value = PistonHeadRenderer.class, priority = 1200)
23
public abstract class PistonHeadRendererMixin {
24
    @Inject(
25
            method = "submit(Lnet/minecraft/client/renderer/blockentity/state/PistonHeadRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
26
            at = @At("HEAD"),
27
            cancellable = true
28
    )
29
    private void combatant$noRenderMovingPiston(
30
            PistonHeadRenderState state,
31
            PoseStack poseStack,
32
            SubmitNodeCollector collector,
33
            CameraRenderState cameraState,
34
            CallbackInfo ci
35
    ) {
36
        NoRender noRender = Modules.get(NoRender.class);
37
        if (noRender != null && noRender.offEntity("moving_pistons")) {
38
            ci.cancel();
39
        }
40
    }
41
}
42
PlayerEntityMixinsrc/main/java/combatant/client/mixins/PlayerEntityMixin.javaJava · 165 lines · 6.0 KB
@Mixin(Player.class)
ModifiesPlayer
PlayerEntityMixin.javaJava · 165 lines · 6.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on LiquidBounce
6
 * (https://github.com/CCBlueX/LiquidBounce).
7
 * Copyright (c) 2015-2026 CCBlueX.
8
 *
9
 * LiquidBounce portions are licensed under GPLv3-or-later.
10
 * Combatant modifications are licensed under GPLv3.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins;
15
16
/*
17
 * Parts of attack rotation and keep-sprint related hooks are adapted from
18
 * LiquidBounce (https://github.com/CCBlueX/LiquidBounce).
19
 * Original copyright (c) CCBlueX.
20
 */
21
22
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
24
import net.minecraft.client.Minecraft;
25
import net.minecraft.core.registries.BuiltInRegistries;
26
import net.minecraft.world.entity.player.Player;
27
import net.minecraft.world.item.ItemCooldowns;
28
import net.minecraft.world.item.Items;
29
import net.minecraft.world.phys.Vec3;
30
import org.spongepowered.asm.mixin.Final;
31
import org.spongepowered.asm.mixin.Mixin;
32
import org.spongepowered.asm.mixin.Shadow;
33
import org.spongepowered.asm.mixin.injection.At;
34
import org.spongepowered.asm.mixin.injection.Inject;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
36
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
37
import combatant.client.events.Events;
38
import combatant.client.events.impl.PlayerSafeWalkEvent;
39
import combatant.client.features.module.Modules;
40
import combatant.client.features.module.modules.player.NoDelay;
41
import combatant.client.features.module.modules.combat.TPSSync;
42
import combatant.client.features.module.modules.movement.NoStun;
43
import combatant.client.features.module.modules.movement.Timer;
44
import combatant.client.mixininterface.IPlayerAttackCooldown;
45
import combatant.client.util.aiming.RotationManager;
46
47
@Mixin(Player.class)
48
public abstract class PlayerEntityMixin implements IPlayerAttackCooldown {
49
50
    @Shadow
51
    @Final
52
    private ItemCooldowns cooldowns;
53
54
    @Inject(method = "isStayingOnGroundSurface", at = @At("RETURN"), cancellable = true)
55
    private void combatant$safeWalk(CallbackInfoReturnable<Boolean> cir) {
56
        if (cir.getReturnValue()) return;
57
        if ((Object) this != Minecraft.getInstance().player) return;
58
        if (!Events.BUS.hasListeners(PlayerSafeWalkEvent.class)) return;
59
60
        PlayerSafeWalkEvent event = new PlayerSafeWalkEvent();
61
        Events.BUS.post(event);
62
        if (event.isSafeWalk()) {
63
            cir.setReturnValue(true);
64
        }
65
    }
66
67
    @Inject(method = "isMobilityRestricted", at = @At("HEAD"), cancellable = true)
68
    private void combatant$noStunBlindnessSprint(CallbackInfoReturnable<Boolean> cir) {
69
        NoStun noStun = Modules.get(NoStun.class);
70
        if (noStun != null && noStun.shouldIgnoreBlindness((Player) (Object) this)) {
71
            cir.setReturnValue(false);
72
        }
73
    }
74
75
    @ModifyExpressionValue(
76
            method = "causeExtraKnockback",
77
            at = @At(
78
                    value = "INVOKE",
79
                    target = "Lnet/minecraft/world/entity/player/Player;getYRot()F"
80
            )
81
    )
82
    private float combatant$fixKnockbackYaw(float original) {
83
        if ((Object) this != Minecraft.getInstance().player) {
84
            return original;
85
        }
86
        return RotationManager.INSTANCE.getMovementRotation().yaw();
87
    }
88
89
    @ModifyExpressionValue(
90
            method = "doSweepAttack",
91
            at = @At(
92
                    value = "INVOKE",
93
                    target = "Lnet/minecraft/world/entity/player/Player;getYRot()F"
94
            )
95
    )
96
    private float combatant$fixSweepYaw(float original) {
97
        if ((Object) this != Minecraft.getInstance().player) {
98
            return original;
99
        }
100
        return RotationManager.INSTANCE.getMovementRotation().yaw();
101
    }
102
103
    @ModifyExpressionValue(
104
            method = "travel",
105
            at = @At(
106
                    value = "INVOKE",
107
                    target = "Lnet/minecraft/world/entity/player/Player;getLookAngle()Lnet/minecraft/world/phys/Vec3;"
108
            )
109
    )
110
    private Vec3 combatant$fixTravelRotationVector(Vec3 original) {
111
        if ((Object) this != Minecraft.getInstance().player) {
112
            return original;
113
        }
114
        return RotationManager.INSTANCE.getMovementRotation().directionVector();
115
    }
116
117
    @Inject(method = "tick", at = @At("HEAD"))
118
    private void handleShieldCooldown(CallbackInfo ci) {
119
        NoDelay noDelay = Modules.get(NoDelay.class);
120
        if (noDelay == null || !noDelay.shouldDisableShieldCooldown()) return;
121
122
        cooldowns.removeCooldown(BuiltInRegistries.ITEM.getKey(Items.SHIELD));
123
    }
124
125
    /**
126
     * Синхронизация attack cooldown с серверным TPS.
127
     * НЕ трогает ItemCooldownManager.
128
     * НЕ влияет на shield.
129
     */
130
    @ModifyReturnValue(
131
            method = "getCurrentItemAttackStrengthDelay",
132
            at = @At("RETURN")
133
    )
134
    private float combatant$tpsSyncAttackCooldown(float original) {
135
        float result = original;
136
137
        TPSSync tpsSync = Modules.get(TPSSync.class);
138
        if (tpsSync != null && tpsSync.isEnabled()) {
139
            float serverDelta = tpsSync.getServerTickDelta();
140
            if (serverDelta > 0.0f && serverDelta < 1.0f) {
141
                // замедляем заполнение cooldown’а под TPS
142
                result = result / serverDelta;
143
            }
144
        }
145
146
        float timerMult = Timer.getTickTimer();
147
        if (timerMult > 0.0001f && Math.abs(timerMult - 1.0f) > 0.0001f) {
148
            result = result * timerMult;
149
        }
150
151
        return result;
152
    }
153
154
    @Override
155
    public float combatant$getAttackCooldownProgress(float tickDelta) {
156
        Player self = (Player) (Object) this;
157
        return self.getAttackStrengthScale(tickDelta);
158
    }
159
160
    @Override
161
    public boolean combatant$isAttackCharged(float tickDelta) {
162
        return combatant$getAttackCooldownProgress(tickDelta) >= 1.0f;
163
    }
164
}
165
PlayerInfoMixinsrc/main/java/combatant/client/mixins/PlayerInfoMixin.javaJava · 111 lines · 3.7 KB
@Mixin(PlayerInfo.class)
ModifiesPlayerInfo
PlayerInfoMixin.javaJava · 111 lines · 3.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.authlib.GameProfile;
11
import net.minecraft.client.multiplayer.PlayerInfo;
12
import net.minecraft.network.chat.Component;
13
import net.minecraft.network.chat.ComponentContents;
14
import net.minecraft.network.chat.MutableComponent;
15
import net.minecraft.network.chat.contents.PlainTextContents;
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.callback.CallbackInfoReturnable;
22
import combatant.client.features.gui.hud.nondraggable.impl.tab.CustomTabList;
23
import combatant.client.features.module.Modules;
24
import combatant.client.features.module.modules.misc.BetterMinecraft;
25
import combatant.client.features.relations.CategoryService;
26
import combatant.client.features.relations.CategoryType;
27
28
@Mixin(PlayerInfo.class)
29
public abstract class PlayerInfoMixin {
30
31
    @Shadow
32
    public abstract GameProfile getProfile();
33
34
    @Inject(method = "getTabListDisplayName", at = @At("RETURN"), cancellable = true)
35
    private void injectColorIntoTab(CallbackInfoReturnable<Component> cir) {
36
        if (CustomTabList.shouldReplaceVanilla()) return;
37
38
        BetterMinecraft module = Modules.get(BetterMinecraft.class);
39
        if (module == null || !module.isTablistRelationsEnabled()) return;
40
41
        Component original = cir.getReturnValue();
42
        if (original == null) return;
43
44
        GameProfile profile = getProfile();
45
        if (profile == null) return;
46
47
        String name = profile.name();
48
        if (name == null) return;
49
50
        // category (friend/enemy/staff/default)
51
        CategoryType type = CategoryService.get(name);
52
53
        if (type == CategoryType.DEFAULT)
54
            return;
55
56
        int color = CategoryService.getColor(name);
57
58
        MutableComponent modified = recolorNameOnly(original, name, color);
59
60
        cir.setReturnValue(modified);
61
    }
62
63
    @Unique
64
    private MutableComponent recolorNameOnly(Component text, String name, int color) {
65
66
        ComponentContents content = text.getContents();
67
        MutableComponent result;
68
69
        if (content instanceof PlainTextContents plain) {
70
71
            String raw = plain.text();
72
            String rawLower = raw.toLowerCase();
73
            String nameLower = name.toLowerCase();
74
75
            int idx = rawLower.indexOf(nameLower);
76
77
            if (idx != -1) {
78
                // raw = before + name + after
79
                String before = raw.substring(0, idx);
80
                String mid = raw.substring(idx, idx + name.length());
81
                String after = raw.substring(idx + name.length());
82
83
                result = Component.empty();
84
85
                if (!before.isEmpty())
86
                    result.append(Component.literal(before).withStyle(text.getStyle()));
87
88
                result.append(
89
                        Component.literal(mid)
90
                                .withStyle(style -> style.withColor(color))
91
                );
92
93
                if (!after.isEmpty())
94
                    result.append(Component.literal(after).withStyle(text.getStyle()));
95
96
            } else {
97
                result = Component.literal(raw).withStyle(text.getStyle());
98
            }
99
100
        } else {
101
            result = MutableComponent.create(content).withStyle(text.getStyle());
102
        }
103
104
        for (Component child : text.getSiblings()) {
105
            result.append(recolorNameOnly(child, name, color));
106
        }
107
108
        return result;
109
    }
110
}
111
PlayerInventoryMixinsrc/main/java/combatant/client/mixins/PlayerInventoryMixin.javaJava · 48 lines · 1.5 KB
@Mixin(Inventory.class)
ModifiesInventory
PlayerInventoryMixin.javaJava · 48 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
11
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
12
import net.minecraft.client.Minecraft;
13
import net.minecraft.world.entity.player.Inventory;
14
import net.minecraft.world.entity.player.Player;
15
import net.minecraft.world.item.ItemStack;
16
import org.spongepowered.asm.mixin.Final;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.Shadow;
19
import org.spongepowered.asm.mixin.injection.At;
20
import combatant.client.util.player.inventory.InventorySwap;
21
22
@Mixin(Inventory.class)
23
public abstract class PlayerInventoryMixin {
24
25
    @Shadow
26
    @Final
27
    public Player player;
28
29
    @Shadow
30
    public abstract ItemStack getItem(int slot);
31
32
    @ModifyReturnValue(method = "getSelectedSlot", at = @At("RETURN"))
33
    private int combatant$silentSelectedSlot(int original) {
34
        Minecraft mc = Minecraft.getInstance();
35
        return player == mc.player ? InventorySwap.INSTANCE.effectiveSelectedSlot() : original;
36
    }
37
38
    @ModifyReturnValue(method = "getSelectedItem", at = @At("RETURN"))
39
    private ItemStack combatant$silentSelectedStack(ItemStack original) {
40
        Minecraft mc = Minecraft.getInstance();
41
        if (player == mc.player && InventorySwap.INSTANCE.isHotbarLeased()) {
42
            return getItem(InventorySwap.INSTANCE.effectiveSelectedSlot());
43
        }
44
45
        return original;
46
    }
47
}
48
PlayerTabOverlayMixinsrc/main/java/combatant/client/mixins/PlayerTabOverlayMixin.javaJava · 39 lines · 1.6 KB
@Mixin(PlayerTabOverlay.class)
PlayerTabOverlayMixin.javaJava · 39 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.features.gui.hud.nondraggable.impl.tab.CustomTabList;
11
import combatant.client.runtime.RuntimeGate;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.PlayerTabOverlay;
14
import net.minecraft.world.scores.Objective;
15
import net.minecraft.world.scores.Scoreboard;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
21
@Mixin(PlayerTabOverlay.class)
22
public abstract class PlayerTabOverlayMixin {
23
    @Inject(
24
            method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V",
25
            at = @At("HEAD"),
26
            cancellable = true
27
    )
28
    private void combatant$extractCustomTabList(GuiGraphicsExtractor context,
29
                                                int width,
30
                                                Scoreboard scoreboard,
31
                                                Objective objective,
32
                                                CallbackInfo ci) {
33
        if (RuntimeGate.isPanic()) return;
34
        if (!CustomTabList.shouldReplaceVanilla()) return;
35
        CustomTabList.renderVanillaTabStratum(context, width);
36
        ci.cancel();
37
    }
38
}
39
PowderSnowFogModifierMixinsrc/main/java/combatant/client/mixins/PowderSnowFogModifierMixin.javaJava · 52 lines · 1.9 KB
@Mixin(value = PowderedSnowFogEnvironment.class, priority = 1200)priority 1200
PowderSnowFogModifierMixin.javaJava · 52 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.multiplayer.ClientLevel;
13
import net.minecraft.client.renderer.fog.FogData;
14
import net.minecraft.client.renderer.fog.environment.PowderedSnowFogEnvironment;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.visuals.WorldTweaks;
21
22
@Mixin(value = PowderedSnowFogEnvironment.class, priority = 1200)
23
public class PowderSnowFogModifierMixin {
24
25
    @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
26
    private void combatant$noPowderFog(FogData data,
27
                                       Camera camera,
28
                                       ClientLevel world,
29
                                       float viewDistance,
30
                                       DeltaTracker tickCounter,
31
                                       CallbackInfo ci) {
32
        WorldTweaks module = Modules.get(WorldTweaks.class);
33
        if (module == null || !module.isFogControlEnabled()) return;
34
        if (module.isFogModifyEnabled()) {
35
            module.applyFogOverride(data);
36
            ci.cancel();
37
            return;
38
        }
39
        if (!module.disablePowderSnowFog()) return;
40
41
        float far = Math.max(viewDistance, 16.0f);
42
        data.environmentalStart = far;
43
        data.environmentalEnd = far;
44
        data.renderDistanceStart = far;
45
        data.renderDistanceEnd = far;
46
        data.skyEnd = far;
47
        data.cloudEnd = far;
48
        ci.cancel();
49
    }
50
}
51
52
ProjectileUtilMixinsrc/main/java/combatant/client/mixins/ProjectileUtilMixin.javaJava · 85 lines · 3.6 KB
@Mixin(ProjectileUtil.class)
ProjectileUtilMixin.javaJava · 85 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.world.entity.Entity;
11
import net.minecraft.world.entity.LivingEntity;
12
import net.minecraft.world.entity.projectile.ProjectileUtil;
13
import net.minecraft.world.level.Level;
14
import net.minecraft.world.phys.AABB;
15
import net.minecraft.world.phys.Vec3;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Redirect;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.combat.Hitbox;
21
22
import java.util.ArrayList;
23
import java.util.List;
24
import java.util.function.Predicate;
25
26
@Mixin(ProjectileUtil.class)
27
public class ProjectileUtilMixin {
28
29
    // Intercept getOtherEntities in ProjectileUtil.raycast:
30
    // - If Hitbox is disabled/panic -> keep vanilla list.
31
    // - If enabled -> drop dead LivingEntity and those Hitbox wants to ignore.
32
    @Redirect(
33
            method = "getEntityHitResult(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;D)Lnet/minecraft/world/phys/EntityHitResult;",
34
            at = @At(
35
                    value = "INVOKE",
36
                    target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;"
37
            )
38
    )
39
    private static List<Entity> combatant$filterEntities(Level world, Entity source, AABB box, Predicate<Entity> predicate) {
40
        List<Entity> original = world.getEntities(source, box, predicate);
41
        if (original == null || original.isEmpty()) return original;
42
43
        Hitbox hb = Modules.get(Hitbox.class);
44
        if (hb == null || !hb.isEnabled()) return original;
45
46
        List<Entity> filtered = new ArrayList<>(original.size());
47
        for (Entity e : original) {
48
            if (e instanceof LivingEntity living && !living.isAlive()) continue;
49
            if (hb.shouldIgnore(e)) continue;
50
            filtered.add(e);
51
        }
52
53
        return filtered;
54
    }
55
56
    // Intercept getBoundingBox: add padding only for live targets allowed by Hitbox.
57
    @Redirect(
58
            method = "getEntityHitResult(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;D)Lnet/minecraft/world/phys/EntityHitResult;",
59
            at = @At(
60
                    value = "INVOKE",
61
                    target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;"
62
            )
63
    )
64
    private static AABB combatant$padBoundingBox(Entity target,
65
                                                 Entity source,
66
                                                 Vec3 start,
67
                                                 Vec3 end,
68
                                                 AABB box,
69
                                                 Predicate<Entity> predicate,
70
                                                 double maxDistance) {
71
        Hitbox hb = Modules.get(Hitbox.class);
72
        AABB bb = target.getBoundingBox();
73
        if (hb == null || !hb.shouldExpandFor(target)) {
74
            return bb;
75
        }
76
77
        double baseDistanceSq = Hitbox.boxDistanceSq(bb, start);
78
        if (baseDistanceSq > maxDistance) {
79
            return bb;
80
        }
81
82
        return bb.inflate(hb.getPadding());
83
    }
84
}
85
RecipeBookScreenMixinsrc/main/java/combatant/client/mixins/RecipeBookScreenMixin.javaJava · 37 lines · 1.2 KB
@Mixin(AbstractRecipeBookScreen.class)
RecipeBookScreenMixin.javaJava · 37 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen;
11
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Shadow;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.module.Modules;
19
import combatant.client.features.module.modules.misc.BetterMinecraft;
20
21
@Mixin(AbstractRecipeBookScreen.class)
22
public abstract class RecipeBookScreenMixin {
23
24
    @Final
25
    @Shadow
26
    private RecipeBookComponent<?> recipeBookComponent;
27
28
    @Inject(method = "initButton", at = @At("HEAD"), cancellable = true)
29
    private void combatant$disableRecipeBook(CallbackInfo ci) {
30
        BetterMinecraft module = Modules.get(BetterMinecraft.class);
31
        if (module != null && module.isHideRecipeBookEnabled()) {
32
            ci.cancel();
33
        }
34
    }
35
}
36
37
ReloadableResourceManagerMixinsrc/main/java/combatant/client/mixins/ReloadableResourceManagerMixin.javaJava · 38 lines · 1.1 KB
@Mixin(ReloadableResourceManager.class)
ReloadableResourceManagerMixin.javaJava · 38 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.server.packs.PackType;
11
import net.minecraft.server.packs.resources.ReloadableResourceManager;
12
import org.slf4j.Logger;
13
import org.spongepowered.asm.mixin.Final;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.Shadow;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Redirect;
18
19
@Mixin(ReloadableResourceManager.class)
20
public abstract class ReloadableResourceManagerMixin {
21
    @Final
22
    @Shadow
23
    private PackType type;
24
25
    @Redirect(
26
            method = "createReload",
27
            at = @At(
28
                    value = "INVOKE",
29
                    target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V"
30
            )
31
    )
32
    private void combatant$suppressClientResourceReloadLog(Logger logger, String format, Object packs) {
33
        if (type != PackType.CLIENT_RESOURCES) {
34
            logger.info(format, packs);
35
        }
36
    }
37
}
38
RenderPassMixinsrc/main/java/combatant/client/mixins/RenderPassMixin.javaJava · 30 lines · 1.0 KB
@Mixin(RenderPass.class)
ModifiesRenderPass
RenderPassMixin.javaJava · 30 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.pipeline.RenderPipeline;
11
import com.mojang.blaze3d.systems.RenderPass;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.render.engine.core.CombatantRenderSystem;
17
import combatant.client.util.logging.DebugLog;
18
19
@Mixin(RenderPass.class)
20
public abstract class RenderPassMixin {
21
    @Inject(method = "setPipeline", at = @At("RETURN"))
22
    private void combatant$applyRhiPipelineState(RenderPipeline pipeline, CallbackInfo ci) {
23
        try {
24
            CombatantRenderSystem.rhi().pipelineState().applyPipelineState(pipeline);
25
        } catch (Throwable t) {
26
            DebugLog.error("[ShapeClip] pipeline state hook failed for " + pipeline, t);
27
        }
28
    }
29
}
30
RenderPipelineMixinsrc/main/java/combatant/client/mixins/RenderPipelineMixin.javaJava · 79 lines · 2.6 KB
@Mixin(RenderPipeline.class)
RenderPipelineMixin.javaJava · 79 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on, adapted from, or implemented
6
 * with reference to Meteor Client
7
 * (https://github.com/MeteorDevelopment/meteor-client).
8
 * Copyright (c) Meteor Development.
9
 *
10
 * Licensed under the GNU General Public License v3.0.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins;
15
16
import com.mojang.blaze3d.pipeline.RenderPipeline;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.Unique;
19
import combatant.client.mixininterface.IRenderPipeline;
20
import combatant.client.render.engine.rhi.clip.ShapeClipRenderPassContract;
21
import combatant.client.render.engine.pipeline.RenderPipelineContract;
22
import combatant.client.render.engine.rhi.pipeline.PipelineDomain;
23
import combatant.client.render.engine.rhi.pipeline.PipelineMetadata;
24
25
@Mixin(RenderPipeline.class)
26
public abstract class RenderPipelineMixin implements IRenderPipeline {
27
    @Unique
28
    private boolean combatant$lineSmooth;
29
30
    @Unique
31
    private ShapeClipRenderPassContract combatant$shapeClipContract = ShapeClipRenderPassContract.NONE;
32
33
    @Unique
34
    private RenderPipelineContract combatant$contract = RenderPipelineContract.EXTENDED;
35
36
    @Unique
37
    private PipelineMetadata combatant$metadata = PipelineMetadata.builder(PipelineDomain.UNKNOWN).build();
38
39
    @Override
40
    public void combatant$setLineSmooth(boolean lineSmooth) {
41
        this.combatant$lineSmooth = lineSmooth;
42
    }
43
44
    @Override
45
    public boolean combatant$getLineSmooth() {
46
        return combatant$lineSmooth;
47
    }
48
49
    @Override
50
    public void combatant$setShapeClipContract(ShapeClipRenderPassContract contract) {
51
        this.combatant$shapeClipContract = contract == null ? ShapeClipRenderPassContract.NONE : contract;
52
    }
53
54
    @Override
55
    public ShapeClipRenderPassContract combatant$getShapeClipContract() {
56
        return combatant$shapeClipContract;
57
    }
58
59
    @Override
60
    public void combatant$setContract(RenderPipelineContract contract) {
61
        this.combatant$contract = contract == null ? RenderPipelineContract.EXTENDED : contract;
62
    }
63
64
    @Override
65
    public RenderPipelineContract combatant$getContract() {
66
        return combatant$contract;
67
    }
68
69
    @Override
70
    public void combatant$setMetadata(PipelineMetadata metadata) {
71
        this.combatant$metadata = metadata != null ? metadata : PipelineMetadata.builder(PipelineDomain.UNKNOWN).build();
72
    }
73
74
    @Override
75
    public PipelineMetadata combatant$getMetadata() {
76
        return combatant$metadata;
77
    }
78
}
79
ScreenEffectRendererMixinsrc/main/java/combatant/client/mixins/ScreenEffectRendererMixin.javaJava · 86 lines · 3.0 KB
@Mixin(ScreenEffectRenderer.class)
ScreenEffectRendererMixin.javaJava · 86 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.renderer.ScreenEffectRenderer;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
15
import net.minecraft.world.effect.MobEffects;
16
import net.minecraft.world.entity.player.Player;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Redirect;
20
import combatant.client.features.module.Modules;
21
import combatant.client.features.module.modules.visuals.NoRender;
22
import combatant.client.mixins.accessors.InGameOverlayRendererAccessor;
23
24
@Mixin(ScreenEffectRenderer.class)
25
public abstract class ScreenEffectRendererMixin {
26
27
    @Redirect(
28
            method = "submit",
29
            at = @At(
30
                    value = "INVOKE",
31
                    target =
32
                            "Lnet/minecraft/client/renderer/ScreenEffectRenderer;submitFire(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;)V"
33
            )
34
    )
35
    private static void combatant$maybeRenderFireOverlay(
36
            PoseStack matrices,
37
            SubmitNodeCollector vertexConsumers,
38
            TextureAtlasSprite sprite
39
    ) {
40
        Minecraft client = Minecraft.getInstance();
41
        Player player = client.player;
42
        if (player == null) return;
43
44
        NoRender noRender = Modules.get(NoRender.class);
45
        if (noRender != null && noRender.off("fire_overlay")) {
46
            if (!noRender.fireOnlyWhenResistant()) {
47
                return;
48
            }
49
            if (player.hasEffect(MobEffects.FIRE_RESISTANCE)) {
50
                return;
51
            }
52
        }
53
54
        if (player.hasEffect(MobEffects.FIRE_RESISTANCE)) {
55
            return;
56
        }
57
58
        InGameOverlayRendererAccessor.callRenderFireOverlay(matrices, vertexConsumers, sprite);
59
    }
60
61
    @Redirect(
62
            method = "submit",
63
            at = @At(
64
                    value = "INVOKE",
65
                    target =
66
                            "Lnet/minecraft/client/renderer/ScreenEffectRenderer;submitBlockSprite(Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V"
67
            )
68
    )
69
    private static void combatant$maybeRenderBlockOverlay(
70
            TextureAtlasSprite sprite,
71
            PoseStack matrices,
72
            SubmitNodeCollector vertexConsumers,
73
            int color
74
    ) {
75
        NoRender noRender = Modules.get(NoRender.class);
76
        if (noRender != null && noRender.off("block_overlay")) {
77
            return;
78
        }
79
80
        InGameOverlayRendererAccessor.callRenderInWallOverlay(sprite, matrices, vertexConsumers, color);
81
    }
82
}
83
84
85
86
ScreenMixinsrc/main/java/combatant/client/mixins/ScreenMixin.javaJava · 191 lines · 9.6 KB
@Mixin(Screen.class)
ModifiesScreen
ScreenMixin.javaJava · 191 lines · 9.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.gui.GuiGraphicsExtractor;
12
import net.minecraft.client.gui.screens.Screen;
13
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
14
import net.minecraft.network.chat.ClickEvent;
15
import net.minecraft.util.Mth;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
22
import combatant.client.features.command.CommandManager;
23
import combatant.client.features.theme.Theme;
24
import combatant.client.features.gui.hud.HudRenderUtil;
25
import combatant.client.features.theme.Themes;
26
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
27
import combatant.client.features.gui.hud.nondraggable.impl.BetterTooltips;
28
import combatant.client.features.module.Modules;
29
import combatant.client.features.module.modules.visuals.NoRender;
30
import combatant.client.render.engine.core.CombatantRenderSystem;
31
import combatant.client.render.engine.animation.AnimationUtility;
32
import combatant.client.render.engine.core.ViewportContext;
33
import combatant.client.render.engine.renderer.Renderer2D;
34
import combatant.client.render.engine.svg.SvgRenderOptions;
35
import combatant.client.render.engine.core.RenderPhase;
36
import combatant.client.render.engine.core.RenderPhaseScope;
37
import combatant.client.util.NarratorBlocker;
38
import combatant.client.util.proxy.ProxyBackend;
39
import combatant.client.util.proxy.ProxyEntry;
40
41
@Mixin(Screen.class)
42
public abstract class ScreenMixin {
43
    @Unique
44
    private RenderPhaseScope combatant$screenPhaseScope;
45
46
    @Inject(method = "defaultHandleGameClickEvent", at = @At("HEAD"), cancellable = true)
47
    private static void combatant$runClientChatCommand(ClickEvent event,
48
                                                       Minecraft client,
49
                                                       Screen screen,
50
                                                       CallbackInfo ci) {
51
        if (!(event instanceof ClickEvent.RunCommand run)) return;
52
        String command = run.command();
53
        if (command == null || !command.startsWith("@")) return;
54
        if (CommandManager.handle(command)) {
55
            ci.cancel();
56
        }
57
    }
58
59
    @Inject(method = "shouldRunNarration", at = @At("HEAD"), cancellable = true)
60
    private void combatant$disableNarratorUi(CallbackInfoReturnable<Boolean> cir) {
61
        if (!NarratorBlocker.isBlocked()) return;
62
        cir.setReturnValue(false);
63
    }
64
65
    @Inject(method = "extractBackground(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
66
    private void combatant$noRender$cancelDarkening(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
67
        NoRender module = Modules.get(NoRender.class);
68
        Minecraft mc = Minecraft.getInstance();
69
        if (module != null && mc != null && mc.level != null && module.screenDarkeningDisabled()) {
70
            ci.cancel();
71
        }
72
    }
73
74
    @Inject(method = "extractTransparentBackground(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V", at = @At("HEAD"), cancellable = true)
75
    private void combatant$noRender$cancelInGameBackground(GuiGraphicsExtractor context, CallbackInfo ci) {
76
        NoRender module = Modules.get(NoRender.class);
77
        Minecraft mc = Minecraft.getInstance();
78
        if (module != null && mc != null && mc.level != null && module.screenDarkeningDisabled()) {
79
            ci.cancel();
80
        }
81
    }
82
83
    @Inject(method = "extractRenderStateWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"))
84
    private void combatant$beginButtonQueue(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
85
        BetterTooltips.beginTooltipFrame();
86
        BetterTooltips.setDrawContext(ctx);
87
        BetterButtons.beginFrame(ctx);
88
    }
89
90
    @Inject(method = "extractRenderStateWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"))
91
    private void combatant$phaseScreenHead(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
92
        Screen self = (Screen) (Object) this;
93
        String label = "2d:screen:" + self.getClass().getSimpleName();
94
        CombatantRenderSystem.ensureFrameContext();
95
        combatant$screenPhaseScope = CombatantRenderSystem.phase(RenderPhase.SCREEN, label);
96
    }
97
98
    @Inject(method = "extractRenderStateWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("RETURN"))
99
    private void combatant$phaseScreenTail(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
100
        Screen self = (Screen) (Object) this;
101
        String label = "2d:screen:" + self.getClass().getSimpleName();
102
        if (combatant$screenPhaseScope != null) {
103
            combatant$screenPhaseScope.close();
104
            combatant$screenPhaseScope = null;
105
        }
106
    }
107
108
@Unique
109
    private static final float COMBATANT_PROXY_BUTTON_X = 8f;
110
    @Unique
111
    private static final float COMBATANT_PROXY_BUTTON_Y = 8f;
112
    @Unique
113
    private static final float COMBATANT_PROXY_BUTTON_W = 24f;
114
    @Unique
115
    private static final float COMBATANT_PROXY_BUTTON_H = 24f;
116
    @Unique
117
    private float combatant$proxyHover;
118
    @Unique
119
    private float combatant$proxyPress;
120
121
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("RETURN"))
122
    private void combatant$renderProxyEntry(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
123
        Screen self = (Screen) (Object) this;
124
        if (!(self instanceof JoinMultiplayerScreen)) return;
125
        float dt = AnimationUtility.deltaTime();
126
        boolean hovered = combatant$inside(mouseX, mouseY, COMBATANT_PROXY_BUTTON_X, COMBATANT_PROXY_BUTTON_Y,
127
                COMBATANT_PROXY_BUTTON_W, COMBATANT_PROXY_BUTTON_H);
128
        combatant$proxyHover = combatant$animate(combatant$proxyHover, hovered ? 1f : 0f, dt, 11f);
129
        combatant$proxyPress = combatant$animate(combatant$proxyPress, 0f, dt, 8f);
130
131
        ViewportContext.beginScaled(context);
132
        Renderer2D.COLOR.begin();
133
        try {
134
            combatant$drawProxyButton();
135
        } finally {
136
            Renderer2D.COLOR.render();
137
            ViewportContext.end(context);
138
        }
139
    }
140
141
    @Unique
142
    private void combatant$drawProxyButton() {
143
        float hover = AnimationUtility.easeOutCubic(combatant$proxyHover);
144
        float press = AnimationUtility.easeOutCubic(combatant$proxyPress);
145
        Themes.Theme theme = Theme.theme();
146
        boolean enabled = ProxyBackend.isEnabled();
147
        ProxyEntry active = ProxyBackend.activeProxy();
148
        boolean configured = active.isConfigured();
149
150
        float size = COMBATANT_PROXY_BUTTON_W * (1.0f + hover * 0.035f - press * 0.025f);
151
        float x = COMBATANT_PROXY_BUTTON_X + (COMBATANT_PROXY_BUTTON_W - size) * 0.5f;
152
        float y = COMBATANT_PROXY_BUTTON_Y + (COMBATANT_PROXY_BUTTON_H - size) * 0.5f - hover * 0.35f;
153
        float radius = 5.0f;
154
        float centerX = x + size * 0.5f;
155
        float centerY = y + size * 0.5f;
156
        int accent = enabled && configured ? theme.accent() : 0x8A94A3;
157
        int baseTop = enabled && configured ? 0x222A20 : 0x1B2028;
158
        int baseBottom = enabled && configured ? 0x121812 : 0x10141B;
159
        int fillTop = HudRenderUtil.mixColor(combatant$withAlpha(baseTop, 226), combatant$withAlpha(accent, 96), (enabled && configured ? 0.18f : 0.06f) + hover * 0.12f);
160
        int fillBottom = HudRenderUtil.mixColor(combatant$withAlpha(baseBottom, 236), combatant$withAlpha(accent, 70), (enabled && configured ? 0.12f : 0.04f) + hover * 0.08f);
161
        int stroke = HudRenderUtil.mixColor(combatant$withAlpha(0x46505D, 180), combatant$withAlpha(accent, 218), (enabled && configured ? 0.38f : 0.10f) + hover * 0.35f);
162
        int iconColor = enabled && configured
163
                ? HudRenderUtil.mixColor(combatant$withAlpha(0xFFFFFF, 245), combatant$withAlpha(theme.accent(), 255), 0.18f)
164
                : combatant$withAlpha(0xC5CCD6, 235);
165
166
        Renderer2D.COLOR.roundedRectSoftShadow(x, y + 0.8f, size, size, radius,
167
                7.5f, 0.026f + hover * 0.012f, combatant$withAlpha(0x060810, 96));
168
        Renderer2D.COLOR.roundedRectGradientQuad(x, y, size, size, radius, 1f,
169
                fillTop, fillTop, fillBottom, fillBottom);
170
        Renderer2D.COLOR.roundedRectStrokeGradient(x + 0.5f, y + 0.5f, size - 1.0f, size - 1.0f,
171
                radius - 0.5f, 1f, 0.55f, HudRenderUtil.mixColor(stroke, 0xFFFFFFFF, 0.08f), stroke, 90f);
172
        Renderer2D.COLOR.svg("shield-user", centerX - 5.6f, centerY - 5.6f, 11.2f, 11.2f, SvgRenderOptions.overrideColor(iconColor));
173
    }
174
175
    @Unique
176
    private static float combatant$animate(float current, float target, float dt, float speed) {
177
        float next = AnimationUtility.approach(current, target, dt, speed);
178
        return AnimationUtility.snap(next, target, 0.001f);
179
    }
180
181
    @Unique
182
    private static boolean combatant$inside(float mx, float my, float x, float y, float w, float h) {
183
        return mx >= x && mx <= x + w && my >= y && my <= y + h;
184
    }
185
186
    @Unique
187
    private static int combatant$withAlpha(int rgb, int alpha) {
188
        return (rgb & 0x00FFFFFF) | (Mth.clamp(alpha, 0, 255) << 24);
189
    }
190
}
191
ServerboundUseItemPacketMixinsrc/main/java/combatant/client/mixins/ServerboundUseItemPacketMixin.javaJava · 46 lines · 1.4 KB
@Mixin(ServerboundUseItemPacket.class)
ServerboundUseItemPacketMixin.javaJava · 46 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
11
import net.minecraft.world.InteractionHand;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Mutable;
15
import org.spongepowered.asm.mixin.Shadow;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.util.aiming.RotationManager;
20
import combatant.client.util.aiming.data.Rotation;
21
22
@Mixin(ServerboundUseItemPacket.class)
23
public class ServerboundUseItemPacketMixin {
24
25
    @Mutable
26
    @Shadow
27
    @Final
28
    private float yRot;
29
30
    @Mutable
31
    @Shadow
32
    @Final
33
    private float xRot;
34
35
    @Inject(method = "<init>(Lnet/minecraft/world/InteractionHand;IFF)V", at = @At("RETURN"))
36
    private void combatant$applyRotation(InteractionHand hand, int sequence, float yaw, float pitch, CallbackInfo ci) {
37
        Rotation rotation = RotationManager.INSTANCE.getCurrentRotation();
38
        if (rotation == null) {
39
            return;
40
        }
41
42
        this.yRot = rotation.yaw();
43
        this.xRot = rotation.pitch();
44
    }
45
}
46
ShaderLoaderMixinsrc/main/java/combatant/client/mixins/ShaderLoaderMixin.javaJava · 211 lines · 9.7 KB
@Mixin(ShaderManager.class)
ShaderLoaderMixin.javaJava · 211 lines · 9.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
11
import com.mojang.blaze3d.shaders.ShaderType;
12
import net.minecraft.client.renderer.PostChainConfig;
13
import net.minecraft.client.renderer.ShaderManager;
14
import net.minecraft.resources.Identifier;
15
import net.minecraft.server.packs.resources.Resource;
16
import net.minecraft.server.packs.resources.ResourceManager;
17
import net.minecraft.util.profiling.ProfilerFiller;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Unique;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23
import combatant.client.mixins.accessors.ShaderLoaderDefinitionsAccessor;
24
import combatant.client.mixins.accessors.ShaderSourceKeyAccessor;
25
import combatant.client.render.engine.shader.CombatantShaderSources;
26
import combatant.client.render.engine.deferred.DeferredRuntimeAssets;
27
import combatant.client.render.iris.IrisCompatibilityGuards;
28
import combatant.client.util.logging.DebugLog;
29
import combatant.client.util.resources.RenderResourceReadiness;
30
import combatant.client.util.resources.ResourceReloadHooks;
31
32
import java.lang.reflect.Constructor;
33
import java.util.LinkedHashMap;
34
import java.util.Map;
35
36
@Mixin(ShaderManager.class)
37
public abstract class ShaderLoaderMixin {
38
    @Unique
39
    private static final Identifier COMBATANT_ENTITY_VERTEX = Identifier.fromNamespaceAndPath("combatant", "shaders/core/entity_dither.vsh");
40
    @Unique
41
    private static final Identifier COMBATANT_ENTITY_FRAGMENT = Identifier.fromNamespaceAndPath("combatant", "shaders/core/entity_dither.fsh");
42
    @Unique
43
    private static final Identifier VANILLA_ENTITY_ID = Identifier.withDefaultNamespace("core/entity");
44
    @Unique
45
    private static boolean combatant$loggedEntityOverride;
46
    @Unique
47
    private static boolean combatant$loggedExtendedShaderSources;
48
    @Unique
49
    private static Constructor<?> combatant$shaderSourceKeyConstructor;
50
51
    @Unique
52
    private static boolean combatant$addExtendedShaderSources(ResourceManager resourceManager, Map<Object, String> shaderSources) {
53
        Map<Identifier, Resource> resources = resourceManager.listResources("shaders", CombatantShaderSources::isCombatantExtendedSource);
54
        if (resources.isEmpty()) {
55
            return false;
56
        }
57
58
        int added = 0;
59
        for (Map.Entry<Identifier, Resource> entry : resources.entrySet()) {
60
            Identifier resourceId = entry.getKey();
61
            if (!DeferredRuntimeAssets.shouldPublishExtendedShader(resourceId)) continue;
62
            ShaderType type = CombatantShaderSources.typeByLocation(resourceId);
63
            if (type == null) continue;
64
65
            String source = CombatantShaderSources.load(resourceManager, resourceId, entry.getValue());
66
            shaderSources.put(combatant$newShaderSourceKey(resourceId, type), source);
67
            added++;
68
69
            Identifier canonicalId = CombatantShaderSources.canonicalShaderId(resourceId);
70
            if (!canonicalId.equals(resourceId)) {
71
                shaderSources.put(combatant$newShaderSourceKey(canonicalId, type), source);
72
                added++;
73
            }
74
        }
75
76
        if (added > 0 && !combatant$loggedExtendedShaderSources) {
77
            combatant$loggedExtendedShaderSources = true;
78
            DebugLog.renderThread("[ShaderSource] registered Combatant .vert/.frag sources in ShaderManager: " + added + " keys");
79
        }
80
        return added > 0;
81
    }
82
83
    @Unique
84
    private static boolean combatant$allowVanillaEntityShaderOverride() {
85
        if (IrisCompatibilityGuards.suppressCombatantTerrainShaderOverrides()) {
86
            return false;
87
        }
88
89
        return true;
90
    }
91
92
    @Unique
93
    private static boolean combatant$applyEntityOverride(ResourceManager resourceManager, Map<Object, String> shaderSources) {
94
        String entityFragmentSrc = combatant$loadShaderSource(resourceManager, COMBATANT_ENTITY_FRAGMENT);
95
        String entityVertexSrc = combatant$loadShaderSource(resourceManager, COMBATANT_ENTITY_VERTEX);
96
        if (((entityFragmentSrc == null || entityFragmentSrc.isEmpty()) || (entityVertexSrc == null || entityVertexSrc.isEmpty())) && !combatant$loggedEntityOverride) {
97
            combatant$loggedEntityOverride = true;
98
            DebugLog.warn("[ShaderOverride] entity fade override skipped: combatant entity_dither shader missing");
99
        }
100
101
        if ((entityFragmentSrc == null || entityFragmentSrc.isEmpty()) || (entityVertexSrc == null || entityVertexSrc.isEmpty())) {
102
            return false;
103
        }
104
105
        boolean entityFragmentChanged = false;
106
        boolean entityVertexChanged = false;
107
108
        for (Map.Entry<Object, String> entry : shaderSources.entrySet()) {
109
            Object key = entry.getKey();
110
            if (entityVertexSrc != null && !entityVertexSrc.isEmpty() && combatant$isEntityVertexKey(key)) {
111
                entry.setValue(entityVertexSrc);
112
                entityVertexChanged = true;
113
                continue;
114
            }
115
            if (entityFragmentSrc != null && !entityFragmentSrc.isEmpty() && combatant$isEntityFragmentKey(key)) {
116
                entry.setValue(entityFragmentSrc);
117
                entityFragmentChanged = true;
118
            }
119
        }
120
121
        if ((!entityFragmentChanged || !entityVertexChanged) && !combatant$loggedEntityOverride) {
122
            combatant$loggedEntityOverride = true;
123
            DebugLog.warn("[ShaderOverride] entity fade override skipped: entity shader key not found");
124
        }
125
126
        if (entityFragmentChanged && entityVertexChanged && !combatant$loggedEntityOverride) {
127
            combatant$loggedEntityOverride = true;
128
            DebugLog.renderThread("[ShaderOverride] override applied: core/entity -> combatant entity_dither");
129
        }
130
131
        return entityFragmentChanged || entityVertexChanged;
132
    }
133
134
    @Unique
135
    private static boolean combatant$isEntityFragmentKey(Object key) {
136
        if (!(key instanceof ShaderSourceKeyAccessor accessor)) return false;
137
        return VANILLA_ENTITY_ID.equals(accessor.combatant$getId()) && accessor.combatant$getType() == ShaderType.FRAGMENT;
138
    }
139
140
    @Unique
141
    private static boolean combatant$isEntityVertexKey(Object key) {
142
        if (!(key instanceof ShaderSourceKeyAccessor accessor)) return false;
143
        return VANILLA_ENTITY_ID.equals(accessor.combatant$getId()) && accessor.combatant$getType() == ShaderType.VERTEX;
144
    }
145
146
    @Unique
147
    private static String combatant$loadShaderSource(ResourceManager resourceManager, Identifier id) {
148
        try {
149
            return CombatantShaderSources.load(resourceManager, id);
150
        } catch (Exception e) {
151
            DebugLog.error("[ShaderOverride] read shader override failed: " + id, e);
152
            return null;
153
        }
154
    }
155
156
    @Unique
157
    private static Object combatant$newShaderSourceKey(Identifier id, ShaderType type) {
158
        try {
159
            if (combatant$shaderSourceKeyConstructor == null) {
160
                Class<?> keyClass = Class.forName("net.minecraft.client.renderer.ShaderManager$ShaderSourceKey");
161
                Constructor<?> constructor = keyClass.getDeclaredConstructor(Identifier.class, ShaderType.class);
162
                constructor.setAccessible(true);
163
                combatant$shaderSourceKeyConstructor = constructor;
164
            }
165
            return combatant$shaderSourceKeyConstructor.newInstance(id, type);
166
        } catch (ReflectiveOperationException e) {
167
            throw new IllegalStateException("Failed to create ShaderManager shader source key for " + type + " " + id, e);
168
        }
169
    }
170
171
    @Inject(method = "apply", at = @At("HEAD"))
172
    private void combatant$beforeShaderReload(ShaderManager.Configs definitions,
173
                                              ResourceManager resourceManager,
174
                                              ProfilerFiller profiler,
175
                                              CallbackInfo ci) {
176
        RenderResourceReadiness.markReloading("shader reload");
177
    }
178
179
    @Inject(method = "apply", at = @At("TAIL"))
180
    private void combatant$afterShaderReload(ShaderManager.Configs definitions,
181
                                             ResourceManager resourceManager,
182
                                             ProfilerFiller profiler,
183
                                             CallbackInfo ci) {
184
        ResourceReloadHooks.onReload(resourceManager);
185
    }
186
187
    @ModifyReturnValue(method = "prepare", at = @At("RETURN"))
188
    private ShaderManager.Configs combatant$extendShaderSources(ShaderManager.Configs definitions,
189
                                                                ResourceManager resourceManager,
190
                                                                ProfilerFiller profiler) {
191
        ShaderLoaderDefinitionsAccessor accessor = (ShaderLoaderDefinitionsAccessor) (Object) definitions;
192
        Map<?, String> shaderSources = accessor.combatant$getShaderSources();
193
        Map<Object, String> replaced = new LinkedHashMap<>(shaderSources.size() + 64);
194
        replaced.putAll(shaderSources);
195
196
        boolean changed = combatant$addExtendedShaderSources(resourceManager, replaced);
197
        if (combatant$allowVanillaEntityShaderOverride()) {
198
            changed |= combatant$applyEntityOverride(resourceManager, replaced);
199
        }
200
201
        if (!changed) {
202
            return definitions;
203
        }
204
205
        Map<Identifier, PostChainConfig> postChains = accessor.combatant$getPostChains();
206
        @SuppressWarnings({"rawtypes", "unchecked"})
207
        ShaderManager.Configs updated = new ShaderManager.Configs((Map) replaced, postChains);
208
        return updated;
209
    }
210
}
211
SkyRendererMixinsrc/main/java/combatant/client/mixins/SkyRendererMixin.javaJava · 91 lines · 3.4 KB
@Mixin(SkyRenderer.class)
ModifiesSkyRenderer
SkyRendererMixin.javaJava · 91 lines · 3.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.pipeline.RenderTarget;
11
import com.mojang.blaze3d.vertex.PoseStack;
12
import net.minecraft.client.renderer.SkyRenderer;
13
import net.minecraft.world.level.MoonPhase;
14
import org.objectweb.asm.Opcodes;
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 combatant.client.render.engine.msaa.MsaaWorldTarget;
24
import combatant.client.features.module.Modules;
25
import combatant.client.features.module.modules.visuals.NoRender;
26
27
@Mixin(SkyRenderer.class)
28
public abstract class SkyRendererMixin {
29
    @Shadow
30
    @Final
31
    private RenderTarget renderTarget;
32
33
    @Redirect(
34
            method = {
35
                    "renderSkyDisc",
36
                    "renderDarkDisc",
37
                    "renderSun",
38
                    "renderMoon",
39
                    "renderStars",
40
                    "renderSunriseAndSunset",
41
                    "renderEndSky",
42
                    "renderEndFlash"
43
            },
44
            at = @At(
45
                    value = "FIELD",
46
                    target = "Lnet/minecraft/client/renderer/SkyRenderer;renderTarget:Lcom/mojang/blaze3d/pipeline/RenderTarget;",
47
                    opcode = Opcodes.GETFIELD
48
            )
49
    )
50
    private RenderTarget combatant$currentWorldTarget(SkyRenderer instance) {
51
        RenderTarget msaa = MsaaWorldTarget.getFramebufferOverride();
52
        return msaa != null ? msaa : renderTarget;
53
    }
54
55
@Unique
56
    private static boolean combatant$noRenderOff(String key) {
57
        NoRender noRender = Modules.get(NoRender.class);
58
        return noRender != null && noRender.offWorld(key);
59
    }
60
61
    @Inject(method = "renderSkyDisc", at = @At("HEAD"), cancellable = true)
62
    private void combatant$noRenderSkyDisc(int color, CallbackInfo ci) {
63
        if (combatant$noRenderOff("sky")) ci.cancel();
64
    }
65
66
    @Inject(method = "renderEndSky", at = @At("HEAD"), cancellable = true)
67
    private void combatant$noRenderEndSky(CallbackInfo ci) {
68
        if (combatant$noRenderOff("sky")) ci.cancel();
69
    }
70
71
    @Inject(method = "renderSun", at = @At("HEAD"), cancellable = true)
72
    private void combatant$noRenderSun(float alpha, PoseStack poseStack, CallbackInfo ci) {
73
        if (combatant$noRenderOff("sun")) ci.cancel();
74
    }
75
76
    @Inject(method = "renderMoon", at = @At("HEAD"), cancellable = true)
77
    private void combatant$noRenderMoon(MoonPhase moonPhase, float alpha, PoseStack poseStack, CallbackInfo ci) {
78
        if (combatant$noRenderOff("moon")) ci.cancel();
79
    }
80
81
    @Inject(method = "renderStars", at = @At("HEAD"), cancellable = true)
82
    private void combatant$noRenderStars(float alpha, PoseStack poseStack, CallbackInfo ci) {
83
        if (combatant$noRenderOff("stars")) ci.cancel();
84
    }
85
86
    @Inject(method = "renderSunriseAndSunset", at = @At("HEAD"), cancellable = true)
87
    private void combatant$noRenderSunrise(PoseStack poseStack, float angle, int color, CallbackInfo ci) {
88
        if (combatant$noRenderOff("sun")) ci.cancel();
89
    }
90
}
91
SlimeBlockMixinsrc/main/java/combatant/client/mixins/SlimeBlockMixin.javaJava · 34 lines · 1.2 KB
@Mixin(SlimeBlock.class)
ModifiesSlimeBlock
SlimeBlockMixin.javaJava · 34 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.world.entity.Entity;
12
import net.minecraft.world.level.Level;
13
import net.minecraft.world.level.block.SlimeBlock;
14
import net.minecraft.world.level.block.state.BlockState;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.movement.NoStun;
21
22
@Mixin(SlimeBlock.class)
23
public class SlimeBlockMixin {
24
25
    @Inject(method = "stepOn", at = @At("HEAD"), cancellable = true)
26
    private void nostun$onSteppedOn(Level world, BlockPos pos, BlockState state, Entity entity, CallbackInfo ci) {
27
        NoStun ns = Modules.get(NoStun.class);
28
        if (ns == null || !ns.isEnabled()) return;
29
        if (!ns.isFunctionEnabled(NoStun.fnEnvBlocks())) return;
30
        if (!ns.isEnvBlockEnabled(NoStun.envSlime())) return;
31
        ci.cancel();
32
    }
33
}
34
SoundEngineLifecycleMixinsrc/main/java/combatant/client/mixins/SoundEngineLifecycleMixin.javaJava · 29 lines · 1.0 KB
@Mixin(SoundEngine.class)not in mixin config
ModifiesSoundEngine
SoundEngineLifecycleMixin.javaJava · 29 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
package combatant.client.mixins;
8
9
import combatant.client.util.sound.SoundSystem;
10
import net.minecraft.client.sounds.SoundEngine;
11
import net.minecraft.client.sounds.SoundEngineExecutor;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Shadow;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
19
/** Supplies the real Minecraft audio executor; never creates another OpenAL context. */
20
@Mixin(SoundEngine.class)
21
public abstract class SoundEngineLifecycleMixin {
22
    @Shadow @Final private SoundEngineExecutor executor;
23
24
    @Inject(method = "<init>", at = @At("TAIL"))
25
    private void combatant$attachAudioExecutor(CallbackInfo ci) {
26
        SoundSystem.get().attachExecutor(executor);
27
    }
28
}
29
SpriteIconButtonCenteredIconMixinsrc/main/java/combatant/client/mixins/SpriteIconButtonCenteredIconMixin.javaJava · 43 lines · 1.8 KB
@Mixin(SpriteIconButton.CenteredIcon.class)
SpriteIconButtonCenteredIconMixin.javaJava · 43 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.AbstractWidget;
14
import net.minecraft.client.gui.components.SpriteIconButton;
15
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
21
22
@Mixin(SpriteIconButton.CenteredIcon.class)
23
public abstract class SpriteIconButtonCenteredIconMixin {
24
25
    @Inject(method = "extractContents(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
26
    private void combatant$drawIcon(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
27
        BetterButtons buttons = BetterButtons.get();
28
        if (buttons == null || !buttons.useUiButtons()) return;
29
        Minecraft mc = Minecraft.getInstance();
30
        if (mc != null && ClientScreen.current() instanceof MerchantScreen) return;
31
        SpriteIconButton self = (SpriteIconButton) (Object) this;
32
        AbstractWidget widget = self;
33
34
        boolean hovered = widget.isMouseOver(mouseX, mouseY);
35
        float hover = BetterButtons.updateHover(widget, hovered, mouseX, mouseY);
36
37
        BetterButtons.enqueueTextIconButton(self, true, hover, widget.isActive(), widget.isFocused());
38
39
        ci.cancel();
40
    }
41
}
42
43
SpriteIconButtonTextAndIconMixinsrc/main/java/combatant/client/mixins/SpriteIconButtonTextAndIconMixin.javaJava · 43 lines · 1.8 KB
@Mixin(SpriteIconButton.TextAndIcon.class)
SpriteIconButtonTextAndIconMixin.javaJava · 43 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.util.screen.ClientScreen;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.gui.components.AbstractWidget;
14
import net.minecraft.client.gui.components.SpriteIconButton;
15
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.features.gui.hud.nondraggable.impl.BetterButtons;
21
22
@Mixin(SpriteIconButton.TextAndIcon.class)
23
public abstract class SpriteIconButtonTextAndIconMixin {
24
25
    @Inject(method = "extractContents(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V", at = @At("HEAD"), cancellable = true)
26
    private void combatant$drawIcon(GuiGraphicsExtractor ctx, int mouseX, int mouseY, float delta, CallbackInfo ci) {
27
        BetterButtons buttons = BetterButtons.get();
28
        if (buttons == null || !buttons.useUiButtons()) return;
29
        Minecraft mc = Minecraft.getInstance();
30
        if (mc != null && ClientScreen.current() instanceof MerchantScreen) return;
31
        SpriteIconButton self = (SpriteIconButton) (Object) this;
32
        AbstractWidget widget = self;
33
34
        boolean hovered = widget.isMouseOver(mouseX, mouseY);
35
        float hover = BetterButtons.updateHover(widget, hovered, mouseX, mouseY);
36
37
        BetterButtons.enqueueTextIconButton(self, false, hover, widget.isActive(), widget.isFocused());
38
39
        ci.cancel();
40
    }
41
}
42
43
TextureAtlasMaterialMixinsrc/main/java/combatant/client/mixins/TextureAtlasMaterialMixin.javaJava · 53 lines · 2.1 KB
@Mixin(TextureAtlas.class)not in mixin config
ModifiesTextureAtlas
TextureAtlasMaterialMixin.javaJava · 53 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.render.engine.material.MaterialAtlasManager;
11
import net.minecraft.client.renderer.texture.SpriteContents;
12
import net.minecraft.client.renderer.texture.SpriteLoader;
13
import net.minecraft.client.renderer.texture.TextureAtlas;
14
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
15
import net.minecraft.resources.Identifier;
16
import org.spongepowered.asm.mixin.Final;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.Shadow;
19
import org.spongepowered.asm.mixin.injection.At;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
23
import java.util.List;
24
25
/** Keeps Combatant's companion material atlases on the exact Minecraft block-atlas lifecycle. */
26
@Mixin(TextureAtlas.class)
27
public abstract class TextureAtlasMaterialMixin {
28
    @Shadow @Final private Identifier location;
29
    @Shadow private List<TextureAtlasSprite> sprites;
30
    @Shadow private List<SpriteContents.AnimationState> animatedTexturesStates;
31
    @Shadow private int width;
32
    @Shadow private int height;
33
    @Shadow private int maxMipLevel;
34
35
    @Inject(method = "upload", at = @At("TAIL"))
36
    private void combatant$buildMaterialAtlases(SpriteLoader.Preparations preparations, CallbackInfo ci) {
37
        if (!TextureAtlas.LOCATION_BLOCKS.equals(location)) return;
38
        MaterialAtlasManager.global().rebuild(sprites, animatedTexturesStates, width, height, maxMipLevel);
39
    }
40
41
    @Inject(method = "cycleAnimationFrames", at = @At("TAIL"))
42
    private void combatant$syncMaterialAnimations(CallbackInfo ci) {
43
        if (!TextureAtlas.LOCATION_BLOCKS.equals(location)) return;
44
        MaterialAtlasManager.global().synchronizeAnimations();
45
    }
46
47
    @Inject(method = "clearTextureData", at = @At("HEAD"))
48
    private void combatant$releaseMaterialAtlases(CallbackInfo ci) {
49
        if (!TextureAtlas.LOCATION_BLOCKS.equals(location)) return;
50
        MaterialAtlasManager.global().release();
51
    }
52
}
53
TitleScreenMixinsrc/main/java/combatant/client/mixins/TitleScreenMixin.javaJava · 40 lines · 1.3 KB
@Mixin(TitleScreen.class)
ModifiesTitleScreen
TitleScreenMixin.javaJava · 40 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.config.MainConfig;
11
import combatant.client.util.screen.ClientScreen;
12
import net.minecraft.client.Minecraft;
13
import net.minecraft.client.gui.screens.TitleScreen;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18
import combatant.client.features.gui.mainmenu.CombatantMainMenuScreen;
19
import combatant.client.runtime.RuntimeGate;
20
21
@Mixin(TitleScreen.class)
22
public abstract class TitleScreenMixin {
23
24
    @Inject(method = "init", at = @At("HEAD"), cancellable = true)
25
    private void combatant$replaceTitleScreen(CallbackInfo ci) {
26
        if (!RuntimeGate.canRunRender()) return;
27
        if (!MainConfig.get().isCombatantMainMenuEnabled()) return;
28
        if (CombatantMainMenuScreen.shouldUseVanillaTitleScreen()) return;
29
        Minecraft mc = Minecraft.getInstance();
30
        if (mc == null) return;
31
        if (ClientScreen.current() instanceof CombatantMainMenuScreen) return;
32
        ClientScreen.show(mc, new CombatantMainMenuScreen());
33
        ci.cancel();
34
    }
35
}
36
37
38
39
40
ToastManagerMixinsrc/main/java/combatant/client/mixins/ToastManagerMixin.javaJava · 30 lines · 1.0 KB
@Mixin(ToastManager.class)
ModifiesToastManager
ToastManagerMixin.javaJava · 30 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.gui.components.toasts.Toast;
11
import net.minecraft.client.gui.components.toasts.ToastManager;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.features.module.Modules;
17
import combatant.client.features.module.modules.visuals.NoRender;
18
19
@Mixin(ToastManager.class)
20
public abstract class ToastManagerMixin {
21
22
    @Inject(method = "addToast(Lnet/minecraft/client/gui/components/toasts/Toast;)V", at = @At("HEAD"), cancellable = true)
23
    private void combatant$noRender$hideToasts(Toast toast, CallbackInfo ci) {
24
        NoRender module = Modules.get(NoRender.class);
25
        if (module != null && module.hideToastHints()) {
26
            ci.cancel();
27
        }
28
    }
29
}
30
VulkanCommandEncoderMixinsrc/main/java/combatant/client/mixins/VulkanCommandEncoderMixin.javaJava · 129 lines · 5.9 KB
@Mixin(VulkanCommandEncoder.class)
VulkanCommandEncoderMixin.javaJava · 129 lines · 5.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import com.mojang.blaze3d.systems.RenderPassBackend;
12
import com.mojang.blaze3d.systems.RenderPassDescriptor;
13
import com.mojang.blaze3d.textures.GpuTextureView;
14
import com.mojang.blaze3d.vulkan.VulkanCommandEncoder;
15
import com.mojang.blaze3d.vulkan.VulkanGpuTextureView;
16
import org.lwjgl.vulkan.VkCommandBuffer;
17
import org.spongepowered.asm.mixin.gen.Invoker;
18
import org.spongepowered.asm.mixin.gen.Accessor;
19
import combatant.client.mixininterface.IVulkanCommandEncoderAccess;
20
import org.lwjgl.system.MemoryStack;
21
import org.lwjgl.vulkan.VkClearDepthStencilValue;
22
import combatant.client.render.engine.profiler.UiPipelineTelemetry;
23
import org.lwjgl.vulkan.VkClearValue;
24
import org.lwjgl.vulkan.VkRenderingAttachmentInfo;
25
import org.lwjgl.vulkan.VkRenderingInfo;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.Unique;
28
import org.spongepowered.asm.mixin.injection.At;
29
import org.spongepowered.asm.mixin.injection.Inject;
30
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
31
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
32
import combatant.client.render.engine.core.CombatantRenderSystem;
33
import combatant.client.render.engine.rhi.backend.vulkan.clip.VulkanShapeClipBridge;
34
import combatant.client.render.engine.rhi.backend.vulkan.msaa.VulkanMsaaResolveBridge;
35
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
36
37
import static org.lwjgl.vulkan.VK12.*;
38
39
@Mixin(VulkanCommandEncoder.class)
40
public abstract class VulkanCommandEncoderMixin implements IVulkanCommandEncoderAccess {
41
    @Unique
42
    private boolean combatant$renderPassActive;
43
44
    @Override
45
    @Invoker("commandBuffer")
46
    public abstract VkCommandBuffer combatant$commandBuffer();
47
48
    @Override
49
    public boolean combatant$renderPassActive() {
50
        return combatant$renderPassActive;
51
    }
52
53
    @Override
54
    @Accessor("currentSubmitIndex")
55
    public abstract long combatant$currentSubmitIndex();
56
57
    @Override
58
    @Accessor("completedSubmitIndex")
59
    public abstract long combatant$completedSubmitIndex();
60
61
    @Inject(method = "createRenderPass", at = @At("HEAD"))
62
    private void combatant$beginVulkanRenderPassState(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPassBackend> cir) {
63
        VulkanMsaaResolveBridge.beginRenderPass();
64
        VulkanRenderStateBridge.beginRenderPass(descriptor);
65
    }
66
67
    @Inject(method = "createRenderPass", at = @At("RETURN"))
68
    private void combatant$markRenderPassActive(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPassBackend> cir) {
69
        combatant$renderPassActive = cir.getReturnValue() != null;
70
    }
71
72
73
    @Inject(
74
            method = "createRenderPass",
75
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRDynamicRendering;vkCmdBeginRenderingKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;Lorg/lwjgl/vulkan/VkRenderingInfo;)V", shift = At.Shift.BEFORE)
76
    )
77
    private void combatant$configureAttachments(RenderPassDescriptor descriptor,
78
                                                CallbackInfoReturnable<RenderPassBackend> cir,
79
                                                @Local MemoryStack stack,
80
                                                @Local VkRenderingInfo renderingInfo) {
81
        if (VulkanRenderStateBridge.currentRenderPassNeedsStencilAttachment()) {
82
            GpuTextureView view = VulkanShapeClipBridge.stencilAttachmentFor(descriptor);
83
            if (!(view instanceof VulkanGpuTextureView vkView) || view.isClosed()) {
84
                VulkanRenderStateBridge.markCurrentRenderPassStencilAttachment(false);
85
            } else {
86
                VulkanRenderStateBridge.markCurrentRenderPassStencilAttachment(true);
87
                boolean clear = VulkanShapeClipBridge.consumeStencilClear();
88
                if (clear) UiPipelineTelemetry.recordStencilClear();
89
                VkRenderingAttachmentInfo stencilAttachment = VkRenderingAttachmentInfo.calloc(stack).sType$Default();
90
                stencilAttachment
91
                        .imageView(vkView.vkImageView())
92
                        .imageLayout(VK_IMAGE_LAYOUT_GENERAL)
93
                        .storeOp(VK_ATTACHMENT_STORE_OP_STORE)
94
                        .loadOp(clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD);
95
                if (clear) {
96
                    VkClearDepthStencilValue clearValue = VkClearDepthStencilValue.calloc(stack).depth(0.0f).stencil(0);
97
                    stencilAttachment.clearValue(VkClearValue.calloc(stack).depthStencil(clearValue));
98
                }
99
                renderingInfo.pStencilAttachment(stencilAttachment);
100
            }
101
        }
102
103
        try {
104
            VulkanMsaaResolveBridge.configure(descriptor, renderingInfo);
105
        } catch (Throwable t) {
106
            boolean snapshotResolve = VulkanMsaaResolveBridge.snapshotActive();
107
            VulkanMsaaResolveBridge.abortRenderPass();
108
            if (!snapshotResolve) {
109
                VulkanRenderStateBridge.disableMsaaAfterFailure("dynamic rendering resolve configuration", t);
110
            }
111
            throw t instanceof RuntimeException runtime ? runtime
112
                    : new IllegalStateException("Failed to configure Vulkan MSAA resolve", t);
113
        }
114
    }
115
116
117
    @Inject(method = "submitRenderPass", at = @At("TAIL"))
118
    private void combatant$endVulkanRenderPassState(CallbackInfo ci) {
119
        combatant$renderPassActive = false;
120
        VulkanMsaaResolveBridge.finishRenderPass();
121
        try {
122
            CombatantRenderSystem.rhi().shapeClip().endRenderPass();
123
        } catch (Throwable ignored) {
124
            // Render pass teardown must never make Vulkan submission fail.
125
        }
126
        VulkanRenderStateBridge.endRenderPass();
127
    }
128
}
129
VulkanDeviceMixinsrc/main/java/combatant/client/mixins/VulkanDeviceMixin.javaJava · 247 lines · 11.1 KB
@Mixin(VulkanDevice.class)
ModifiesVulkanDevice
VulkanDeviceMixin.javaJava · 247 lines · 11.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.GpuFormat;
11
import com.mojang.blaze3d.pipeline.RenderPipeline;
12
import com.mojang.blaze3d.shaders.ShaderSource;
13
import com.mojang.blaze3d.textures.GpuTexture;
14
import com.mojang.blaze3d.vulkan.VulkanConst;
15
import com.mojang.blaze3d.vulkan.VulkanDevice;
16
import com.mojang.blaze3d.vulkan.VulkanInstance;
17
import com.mojang.blaze3d.vulkan.VulkanPhysicalDevice;
18
import com.mojang.blaze3d.vulkan.VulkanRenderPipeline;
19
import com.mojang.blaze3d.vulkan.checkpoints.CheckpointExtension;
20
import org.lwjgl.system.MemoryStack;
21
import org.lwjgl.vulkan.VkDevice;
22
import org.lwjgl.vulkan.VkImageFormatProperties;
23
import org.lwjgl.vulkan.VkPhysicalDeviceDepthStencilResolvePropertiesKHR;
24
import org.lwjgl.vulkan.VkPhysicalDeviceFeatures;
25
import org.lwjgl.vulkan.VkPhysicalDeviceLimits;
26
import org.lwjgl.vulkan.VkPhysicalDeviceProperties;
27
import org.lwjgl.vulkan.VkPhysicalDeviceProperties2;
28
import org.spongepowered.asm.mixin.Mixin;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.gen.Invoker;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
36
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
37
import combatant.client.mixininterface.IVulkanBackendInfo;
38
import combatant.client.util.logging.DebugLog;
39
40
import java.util.HashMap;
41
import java.util.Map;
42
import java.util.Set;
43
44
import static org.lwjgl.vulkan.VK12.*;
45
46
@Mixin(VulkanDevice.class)
47
public abstract class VulkanDeviceMixin implements IVulkanBackendInfo {
48
    @Shadow
49
    private ShaderSource defaultShaderSource;
50
51
    @Unique
52
    private final Map<VulkanRenderStateBridge.PipelineVariantKey, VulkanRenderPipeline> combatant$pipelineVariants = new HashMap<>();
53
    @Unique private VkDevice combatant$vkDevice;
54
    @Unique private long combatant$vma;
55
    @Unique private VulkanPhysicalDevice combatant$physicalDevice;
56
    @Unique private long combatant$minStorageBufferOffsetAlignment = 1L;
57
    @Unique private long combatant$maxStorageBufferRange;
58
59
    @Override
60
    public VkDevice combatant$vkDevice() {
61
        return combatant$vkDevice;
62
    }
63
64
    @Override
65
    public long combatant$vma() {
66
        return combatant$vma;
67
    }
68
69
    @Override
70
    public VulkanPhysicalDevice combatant$physicalDevice() {
71
        return combatant$physicalDevice;
72
    }
73
74
    @Override
75
    public long combatant$minStorageBufferOffsetAlignment() {
76
        return combatant$minStorageBufferOffsetAlignment;
77
    }
78
79
    @Override
80
    public long combatant$maxStorageBufferRange() {
81
        return combatant$maxStorageBufferRange;
82
    }
83
84
85
    @Invoker("compilePipeline")
86
    protected abstract VulkanRenderPipeline combatant$compilePipelineVariant(RenderPipeline pipeline, ShaderSource source);
87
88
    @Inject(method = "<init>", at = @At("RETURN"))
89
    private void combatant$captureMsaaCapabilities(ShaderSource shaderSource,
90
                                                   VulkanInstance instance,
91
                                                   VulkanPhysicalDevice physicalDevice,
92
                                                   Set<String> enabledExtensions,
93
                                                   VkDevice device,
94
                                                   long vma,
95
                                                   CheckpointExtension checkpointExtension,
96
                                                   CallbackInfo ci) {
97
        combatant$vkDevice = device;
98
        combatant$vma = vma;
99
        combatant$physicalDevice = physicalDevice;
100
        if (physicalDevice == null) return;
101
102
        try (MemoryStack stack = MemoryStack.stackPush()) {
103
            // Copy the limits we need while querying the VkPhysicalDevice directly. The LWJGL
104
            // structs exposed by Mojang are native-backed views and must not become long-lived
105
            // configuration state for Combatant.
106
            VkPhysicalDeviceProperties deviceProperties = VkPhysicalDeviceProperties.calloc(stack);
107
            vkGetPhysicalDeviceProperties(physicalDevice.vkPhysicalDevice(), deviceProperties);
108
            VkPhysicalDeviceLimits limits = deviceProperties.limits();
109
            combatant$minStorageBufferOffsetAlignment = Math.max(1L, limits.minStorageBufferOffsetAlignment());
110
            combatant$maxStorageBufferRange = Integer.toUnsignedLong(limits.maxStorageBufferRange());
111
            int framebufferSamples = limits.framebufferColorSampleCounts()
112
                    & limits.framebufferDepthSampleCounts()
113
                    & limits.framebufferStencilSampleCounts();
114
115
            VkPhysicalDeviceFeatures features = VkPhysicalDeviceFeatures.calloc(stack);
116
            vkGetPhysicalDeviceFeatures(physicalDevice.vkPhysicalDevice(), features);
117
            VulkanRenderStateBridge.configureAdvancedShaderCapabilities(
118
                    physicalDevice.computeQueueFamilyAndIndex() != null,
119
                    features.tessellationShader(),
120
                    features.geometryShader(),
121
                    combatant$maxStorageBufferRange > 0L
122
            );
123
            int textureUsage = GpuTexture.USAGE_COPY_DST
124
                    | GpuTexture.USAGE_COPY_SRC
125
                    | GpuTexture.USAGE_TEXTURE_BINDING
126
                    | GpuTexture.USAGE_RENDER_ATTACHMENT;
127
            framebufferSamples &= combatant$imageSampleCounts(
128
                    stack,
129
                    physicalDevice,
130
                    GpuFormat.RGBA8_UNORM,
131
                    VulkanConst.textureUsageToVk(textureUsage, GpuFormat.RGBA8_UNORM)
132
            );
133
            framebufferSamples &= combatant$imageSampleCounts(
134
                    stack,
135
                    physicalDevice,
136
                    GpuFormat.D32_FLOAT,
137
                    VulkanConst.textureUsageToVk(textureUsage, GpuFormat.D32_FLOAT)
138
            );
139
            framebufferSamples &= combatant$imageSampleCounts(
140
                    stack,
141
                    physicalDevice,
142
                    GpuFormat.S8_UINT,
143
                    VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
144
            );
145
146
            VkPhysicalDeviceDepthStencilResolvePropertiesKHR resolve =
147
                    VkPhysicalDeviceDepthStencilResolvePropertiesKHR.calloc(stack).sType$Default();
148
            VkPhysicalDeviceProperties2 properties2 = VkPhysicalDeviceProperties2.calloc(stack)
149
                    .sType$Default()
150
                    .pNext(resolve);
151
            vkGetPhysicalDeviceProperties2(physicalDevice.vkPhysicalDevice(), properties2);
152
            VulkanRenderStateBridge.configureMsaaCapabilities(
153
                    framebufferSamples,
154
                    resolve.supportedDepthResolveModes(),
155
                    resolve.independentResolveNone()
156
            );
157
        } catch (Throwable t) {
158
            VulkanRenderStateBridge.configureMsaaCapabilities(1, 0, false);
159
            DebugLog.warnOnChange(
160
                    "msaa.vulkan.capabilities.failed",
161
                    t.getClass().getSimpleName() + "|" + t.getMessage(),
162
                    "[MSAA/Vulkan] capability query failed; MSAA remains disabled: %s: %s",
163
                    t.getClass().getSimpleName(),
164
                    t.getMessage()
165
            );
166
        }
167
    }
168
169
    @Unique
170
    private static int combatant$imageSampleCounts(MemoryStack stack,
171
                                                   VulkanPhysicalDevice physicalDevice,
172
                                                   GpuFormat format,
173
                                                   int usage) {
174
        VkImageFormatProperties properties = VkImageFormatProperties.calloc(stack);
175
        int result = vkGetPhysicalDeviceImageFormatProperties(
176
                physicalDevice.vkPhysicalDevice(),
177
                VulkanConst.toVk(format),
178
                VK_IMAGE_TYPE_2D,
179
                VK_IMAGE_TILING_OPTIMAL,
180
                usage,
181
                0,
182
                properties
183
        );
184
        return result == VK_SUCCESS ? properties.sampleCounts() : VK_SAMPLE_COUNT_1_BIT;
185
    }
186
187
    @Inject(method = "getOrCompilePipeline", at = @At("HEAD"), cancellable = true)
188
    private void combatant$getOrCompilePipelineVariant(RenderPipeline pipeline,
189
                                                       CallbackInfoReturnable<VulkanRenderPipeline> cir) {
190
        if (!VulkanRenderStateBridge.needsPipelineVariant(pipeline)) return;
191
192
        VulkanRenderStateBridge.PipelineVariantKey key = VulkanRenderStateBridge.pipelineVariantKey(pipeline);
193
        VulkanRenderPipeline variant = combatant$pipelineVariants.get(key);
194
        if (variant != null) {
195
            cir.setReturnValue(variant);
196
            return;
197
        }
198
199
        try {
200
            variant = combatant$compilePipelineVariant(pipeline, defaultShaderSource);
201
            if (variant == null || !variant.isValid()) {
202
                throw new IllegalStateException("Vulkan returned an invalid pipeline variant");
203
            }
204
            combatant$pipelineVariants.put(key, variant);
205
            DebugLog.stencilOnChange(
206
                    "vulkan.pipeline.variant.compile",
207
                    key.toString(),
208
                    "[Vulkan/RHI] compiled pipeline variant %s",
209
                    key
210
            );
211
            cir.setReturnValue(variant);
212
        } catch (Throwable t) {
213
            if (key.usesMsaa()) {
214
                VulkanRenderStateBridge.disableMsaaAfterFailure("pipeline variant compile " + key, t);
215
            }
216
            if (key.usesStencil()) {
217
                VulkanRenderStateBridge.disableStencilAfterFailure("pipeline variant compile " + key, t);
218
            }
219
            DebugLog.error("[Vulkan/RHI] pipeline variant compile failed for " + key, t);
220
            // The current dynamic-rendering scope is already active. Falling through to vanilla's
221
            // single-sample/no-stencil pipeline would bind an incompatible VkPipeline and can lose
222
            // the device, so abort on the CPU and only disable the feature for future passes.
223
            throw t instanceof RuntimeException runtime ? runtime
224
                    : new IllegalStateException("Failed to compile Vulkan pipeline variant " + key, t);
225
        }
226
    }
227
228
    @Inject(method = "clearPipelineCache", at = @At("RETURN"))
229
    private void combatant$clearPipelineVariants(CallbackInfo ci) {
230
        if (combatant$pipelineVariants.isEmpty()) return;
231
        for (VulkanRenderPipeline pipeline : combatant$pipelineVariants.values()) {
232
            try {
233
                pipeline.destroy();
234
            } catch (Throwable t) {
235
                DebugLog.warnOnChange(
236
                        "vulkan.pipeline.variant.destroy.failed",
237
                        t.getClass().getSimpleName() + "|" + t.getMessage(),
238
                        "[Vulkan/RHI] failed to destroy pipeline variant: %s: %s",
239
                        t.getClass().getSimpleName(),
240
                        t.getMessage()
241
                );
242
            }
243
        }
244
        combatant$pipelineVariants.clear();
245
    }
246
}
247
VulkanGpuTextureMixinsrc/main/java/combatant/client/mixins/VulkanGpuTextureMixin.javaJava · 119 lines · 5.0 KB
@Mixin(VulkanGpuTexture.class)
VulkanGpuTextureMixin.javaJava · 119 lines · 5.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.GpuFormat;
11
import com.mojang.blaze3d.vulkan.VulkanDevice;
12
import com.mojang.blaze3d.vulkan.VulkanGpuTexture;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Unique;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.Inject;
17
import org.spongepowered.asm.mixin.injection.ModifyArg;
18
import org.spongepowered.asm.mixin.injection.Redirect;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.mixininterface.IMsaaTexture;
21
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
22
import combatant.client.render.engine.rhi.shader.RhiTextureUsage;
23
import org.lwjgl.vulkan.VkImageSubresourceRange;
24
25
import static org.lwjgl.vulkan.VK12.*;
26
27
@Mixin(VulkanGpuTexture.class)
28
public abstract class VulkanGpuTextureMixin implements IMsaaTexture {
29
    @Unique
30
    private int combatant$samples = 1;
31
32
    /**
33
     * Mojang 26.2 maps render-attachment usage only for color/depth aspects. Pure S8_UINT
34
     * is a valid Vulkan stencil attachment, but without this OR the image is created without
35
     * VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT and using it in pStencilAttachment is invalid.
36
     */
37
    @Redirect(
38
            method = "<init>",
39
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vulkan/VulkanConst;textureUsageToVk(ILcom/mojang/blaze3d/GpuFormat;)I")
40
    )
41
    private int combatant$stencilAttachmentUsage(int usage, GpuFormat format) {
42
        int vkUsage = com.mojang.blaze3d.vulkan.VulkanConst.textureUsageToVk(usage, format);
43
        if (format != null && format.hasStencilAspect() && (usage & com.mojang.blaze3d.textures.GpuTexture.USAGE_RENDER_ATTACHMENT) != 0) {
44
            vkUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
45
        }
46
        if ((usage & RhiTextureUsage.STORAGE_IMAGE) != 0) {
47
            vkUsage |= VK_IMAGE_USAGE_STORAGE_BIT;
48
        }
49
        return vkUsage;
50
    }
51
52
    /**
53
     * Mojang picks DEPTH_BIT for every non-color format. For S8_UINT this records an invalid
54
     * initialization barrier and later the image view is invalid too. Keep the patch scoped to
55
     * actual stencil formats; color/depth formats stay vanilla.
56
     */
57
    @Redirect(
58
            method = "<init>",
59
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkImageSubresourceRange;aspectMask(I)Lorg/lwjgl/vulkan/VkImageSubresourceRange;")
60
    )
61
    private VkImageSubresourceRange combatant$stencilImageAspect(VkImageSubresourceRange range,
62
                                                                  int original,
63
                                                                  VulkanDevice device,
64
                                                                  int usage,
65
                                                                  String label,
66
                                                                  GpuFormat format,
67
                                                                  int width,
68
                                                                  int height,
69
                                                                  int depthOrLayers,
70
                                                                  int mipLevels) {
71
        if (format != null && format.hasStencilAspect() && !format.hasDepthAspect()) {
72
            return range.aspectMask(VK_IMAGE_ASPECT_STENCIL_BIT);
73
        }
74
        return range.aspectMask(original);
75
    }
76
77
    @ModifyArg(
78
            method = "<init>",
79
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkImageCreateInfo;samples(I)Lorg/lwjgl/vulkan/VkImageCreateInfo;"),
80
            index = 0
81
    )
82
    private int combatant$useRequestedMsaaSamples(int original) {
83
        return VulkanRenderStateBridge.requestedTextureSamples();
84
    }
85
86
    @Inject(method = "<init>", at = @At("RETURN"))
87
    private void combatant$rememberSamples(VulkanDevice device,
88
                                           int usage,
89
                                           String label,
90
                                           GpuFormat format,
91
                                           int width,
92
                                           int height,
93
                                           int depthOrLayers,
94
                                           int mipLevels,
95
                                           CallbackInfo ci) {
96
        combatant$samples = VulkanRenderStateBridge.requestedTextureSamples();
97
    }
98
99
    @Override
100
    public void combatant$setSamples(int samples) {
101
        combatant$samples = VulkanRenderStateBridge.normalizeSamples(samples);
102
    }
103
104
    @Override
105
    public int combatant$getSamples() {
106
        return combatant$samples;
107
    }
108
109
    @Override
110
    public boolean combatant$isMsaa() {
111
        return combatant$samples > 1;
112
    }
113
114
    @Override
115
    public int combatant$getGlId() {
116
        return 0;
117
    }
118
}
119
VulkanGpuTextureViewMixinsrc/main/java/combatant/client/mixins/VulkanGpuTextureViewMixin.javaJava · 45 lines · 1.9 KB
@Mixin(VulkanGpuTextureView.class)
VulkanGpuTextureViewMixin.javaJava · 45 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.GpuFormat;
11
import com.mojang.blaze3d.vulkan.VulkanDevice;
12
import com.mojang.blaze3d.vulkan.VulkanGpuTexture;
13
import com.mojang.blaze3d.vulkan.VulkanGpuTextureView;
14
import org.lwjgl.vulkan.VkImageSubresourceRange;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Redirect;
18
19
import static org.lwjgl.vulkan.VK12.VK_IMAGE_ASPECT_STENCIL_BIT;
20
21
@Mixin(VulkanGpuTextureView.class)
22
public abstract class VulkanGpuTextureViewMixin {
23
    /**
24
     * Mojang 26.2 treats every non-color view as depth. A pure S8_UINT attachment must use
25
     * STENCIL_BIT or vkCreateImageView is invalid and dynamic rendering cannot bind it as
26
     * pStencilAttachment.
27
     */
28
    @Redirect(
29
            method = "<init>",
30
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkImageSubresourceRange;aspectMask(I)Lorg/lwjgl/vulkan/VkImageSubresourceRange;")
31
    )
32
    private VkImageSubresourceRange combatant$stencilViewAspect(VkImageSubresourceRange range,
33
                                                                 int original,
34
                                                                 VulkanDevice device,
35
                                                                 VulkanGpuTexture texture,
36
                                                                 int baseMipLevel,
37
                                                                 int mipLevels) {
38
        GpuFormat format = texture == null ? null : texture.getFormat();
39
        if (format != null && format.hasStencilAspect() && !format.hasDepthAspect()) {
40
            return range.aspectMask(VK_IMAGE_ASPECT_STENCIL_BIT);
41
        }
42
        return range.aspectMask(original);
43
    }
44
}
45
VulkanRenderPassMixinsrc/main/java/combatant/client/mixins/VulkanRenderPassMixin.javaJava · 53 lines · 2.1 KB
@Mixin(VulkanRenderPass.class)
VulkanRenderPassMixin.javaJava · 53 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.mojang.blaze3d.pipeline.RenderPipeline;
11
import com.mojang.blaze3d.vulkan.VulkanRenderPass;
12
import org.lwjgl.vulkan.VK12;
13
import org.lwjgl.vulkan.VkCommandBuffer;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.gen.Invoker;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
20
21
import java.util.function.Supplier;
22
23
@Mixin(VulkanRenderPass.class)
24
public abstract class VulkanRenderPassMixin {
25
    @Invoker("commandBuffer")
26
    protected abstract VkCommandBuffer combatant$commandBuffer();
27
28
    @Inject(method = "pushDebugGroup", at = @At("HEAD"), cancellable = true)
29
    private void combatant$disableRenderPassDebugGroup(Supplier<String> label, CallbackInfo ci) {
30
        if (!VulkanRenderStateBridge.forceDisableDebugLabels()) return;
31
        ci.cancel();
32
    }
33
34
    @Inject(method = "popDebugGroup", at = @At("HEAD"), cancellable = true)
35
    private void combatant$disableRenderPassDebugGroupPop(CallbackInfo ci) {
36
        if (!VulkanRenderStateBridge.forceDisableDebugLabels()) return;
37
        ci.cancel();
38
    }
39
40
    @Inject(method = "setPipeline", at = @At("TAIL"))
41
    private void combatant$applyDynamicPipelineState(RenderPipeline pipeline, CallbackInfo ci) {
42
        if (!VulkanRenderStateBridge.vulkanBackendActive()) return;
43
        VkCommandBuffer commandBuffer = combatant$commandBuffer();
44
        if (!VulkanRenderStateBridge.forceDisableStencil() && VulkanRenderStateBridge.currentRenderPassHasStencilAttachment()) {
45
            VK12.vkCmdSetStencilReference(
46
                    commandBuffer,
47
                    VK12.VK_STENCIL_FACE_FRONT_AND_BACK,
48
                    VulkanRenderStateBridge.dynamicStencilReference()
49
            );
50
        }
51
    }
52
}
53
VulkanRenderPipelineMixinsrc/main/java/combatant/client/mixins/VulkanRenderPipelineMixin.javaJava · 181 lines · 8.3 KB
@Mixin(VulkanRenderPipeline.class)
VulkanRenderPipelineMixin.javaJava · 181 lines · 8.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import com.mojang.blaze3d.pipeline.RenderPipeline;
12
import com.mojang.blaze3d.vulkan.VulkanBindGroupLayout;
13
import com.mojang.blaze3d.vulkan.VulkanConst;
14
import com.mojang.blaze3d.vulkan.VulkanDevice;
15
import com.mojang.blaze3d.vulkan.VulkanRenderPipeline;
16
import org.lwjgl.system.MemoryStack;
17
import org.lwjgl.vulkan.VkPipelineDepthStencilStateCreateInfo;
18
import org.lwjgl.vulkan.VkPipelineRenderingCreateInfoKHR;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.Unique;
21
import org.spongepowered.asm.mixin.injection.At;
22
import org.spongepowered.asm.mixin.injection.Inject;
23
import org.spongepowered.asm.mixin.injection.ModifyArg;
24
import org.spongepowered.asm.mixin.injection.Redirect;
25
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
26
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
27
28
import java.nio.IntBuffer;
29
30
import static com.mojang.blaze3d.GpuFormat.S8_UINT;
31
import static org.lwjgl.vulkan.VK12.*;
32
33
@Mixin(VulkanRenderPipeline.class)
34
public abstract class VulkanRenderPipelineMixin {
35
    @Inject(method = "compile", at = @At("HEAD"))
36
    private static void combatant$beginCompile(VulkanDevice device,
37
                                               VulkanBindGroupLayout layout,
38
                                               RenderPipeline pipeline,
39
                                               long vertexModule,
40
                                               long fragmentModule,
41
                                               CallbackInfoReturnable<VulkanRenderPipeline> cir) {
42
        if (VulkanRenderStateBridge.vulkanBackendActive()) {
43
            VulkanRenderStateBridge.beginPipelineCompile(pipeline);
44
        }
45
    }
46
47
    @Inject(method = "compile", at = @At("RETURN"))
48
    private static void combatant$endCompile(VulkanDevice device,
49
                                             VulkanBindGroupLayout layout,
50
                                             RenderPipeline pipeline,
51
                                             long vertexModule,
52
                                             long fragmentModule,
53
                                             CallbackInfoReturnable<VulkanRenderPipeline> cir) {
54
        VulkanRenderStateBridge.endPipelineCompile();
55
    }
56
57
    @Redirect(
58
            method = "compile",
59
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;ints(II)Ljava/nio/IntBuffer;")
60
    )
61
    private static IntBuffer combatant$addDynamicStates(MemoryStack stack, int first, int second) {
62
        if (!VulkanRenderStateBridge.vulkanBackendActive()) {
63
            return stack.ints(first, second);
64
        }
65
        if (!VulkanRenderStateBridge.forceDisableStencil()) {
66
            return stack.ints(first, second, VK_DYNAMIC_STATE_STENCIL_REFERENCE);
67
        }
68
        return stack.ints(first, second);
69
    }
70
71
    @ModifyArg(
72
            method = "compile",
73
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkPipelineRasterizationStateCreateInfo;cullMode(I)Lorg/lwjgl/vulkan/VkPipelineRasterizationStateCreateInfo;"),
74
            index = 0
75
    )
76
    private static int combatant$disableCullForStencilMask(int original) {
77
        return VulkanRenderStateBridge.vulkanBackendActive() && VulkanRenderStateBridge.suppressColorWrites() ? VK_CULL_MODE_NONE : original;
78
    }
79
80
    @ModifyArg(
81
            method = "compile",
82
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkPipelineDepthStencilStateCreateInfo;depthTestEnable(Z)Lorg/lwjgl/vulkan/VkPipelineDepthStencilStateCreateInfo;"),
83
            index = 0
84
    )
85
    private static boolean combatant$disableDepthTestForStencilMask(boolean original) {
86
        return (!VulkanRenderStateBridge.vulkanBackendActive() || !VulkanRenderStateBridge.suppressColorWrites()) && original;
87
    }
88
89
    @ModifyArg(
90
            method = "compile",
91
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkPipelineDepthStencilStateCreateInfo;depthWriteEnable(Z)Lorg/lwjgl/vulkan/VkPipelineDepthStencilStateCreateInfo;"),
92
            index = 0
93
    )
94
    private static boolean combatant$disableDepthWriteForStencilMask(boolean original) {
95
        return (!VulkanRenderStateBridge.vulkanBackendActive() || !VulkanRenderStateBridge.suppressColorWrites()) && original;
96
    }
97
98
    @ModifyArg(
99
            method = "compile",
100
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkPipelineMultisampleStateCreateInfo;rasterizationSamples(I)Lorg/lwjgl/vulkan/VkPipelineMultisampleStateCreateInfo;"),
101
            index = 0
102
    )
103
    private static int combatant$useCurrentRenderPassSamples(int original) {
104
        return VulkanRenderStateBridge.vulkanBackendActive() ? VulkanRenderStateBridge.currentVkSampleCount() : original;
105
    }
106
107
    @ModifyArg(
108
            method = "compile",
109
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VkPipelineColorBlendAttachmentState$Buffer;colorWriteMask(I)Lorg/lwjgl/vulkan/VkPipelineColorBlendAttachmentState$Buffer;"),
110
            index = 0
111
    )
112
    private static int combatant$suppressColorWritesForStencilMask(int original) {
113
        return VulkanRenderStateBridge.vulkanBackendActive() && VulkanRenderStateBridge.suppressColorWrites() ? 0 : original;
114
    }
115
116
    @Inject(
117
            method = "compile",
118
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCreateGraphicsPipelines(Lorg/lwjgl/vulkan/VkDevice;JLorg/lwjgl/vulkan/VkGraphicsPipelineCreateInfo$Buffer;Lorg/lwjgl/vulkan/VkAllocationCallbacks;Ljava/nio/LongBuffer;)I", ordinal = 0, shift = At.Shift.BEFORE)
119
    )
120
    private static void combatant$configureStencilPipeline(VulkanDevice device,
121
                                                           VulkanBindGroupLayout layout,
122
                                                           RenderPipeline pipeline,
123
                                                           long vertexModule,
124
                                                           long fragmentModule,
125
                                                           CallbackInfoReturnable<VulkanRenderPipeline> cir,
126
                                                           @Local VkPipelineRenderingCreateInfoKHR rendering,
127
                                                           @Local VkPipelineDepthStencilStateCreateInfo depthStencil) {
128
        if (!VulkanRenderStateBridge.vulkanBackendActive()) return;
129
        if (!VulkanRenderStateBridge.pipelineNeedsStencilFormat(pipeline)) {
130
            depthStencil.stencilTestEnable(false);
131
            rendering.stencilAttachmentFormat(VK_FORMAT_UNDEFINED);
132
            return;
133
        }
134
        rendering.stencilAttachmentFormat(VulkanConst.toVk(S8_UINT));
135
        configureStencilState(depthStencil, pipeline);
136
    }
137
138
    @Unique
139
    private static void configureStencilState(VkPipelineDepthStencilStateCreateInfo state, RenderPipeline pipeline) {
140
        VulkanRenderStateBridge.StencilMode mode = VulkanRenderStateBridge.stencilTestEnabledForCurrentPipeline(pipeline)
141
                ? VulkanRenderStateBridge.stencilMode()
142
                : VulkanRenderStateBridge.StencilMode.DISABLED;
143
        if (mode == VulkanRenderStateBridge.StencilMode.DISABLED) {
144
            state.stencilTestEnable(false);
145
            return;
146
        }
147
148
        int passOp;
149
        int writeMask;
150
        switch (mode) {
151
            case WRITE -> {
152
                passOp = VK_STENCIL_OP_INCREMENT_AND_CLAMP;
153
                writeMask = 0xFF;
154
            }
155
            case RESTORE -> {
156
                passOp = VK_STENCIL_OP_DECREMENT_AND_CLAMP;
157
                writeMask = 0xFF;
158
            }
159
            case TEST -> {
160
                passOp = VK_STENCIL_OP_KEEP;
161
                writeMask = 0x00;
162
            }
163
            default -> {
164
                state.stencilTestEnable(false);
165
                return;
166
            }
167
        }
168
169
        state.stencilTestEnable(true);
170
        state.front()
171
                .failOp(VK_STENCIL_OP_KEEP)
172
                .passOp(passOp)
173
                .depthFailOp(VK_STENCIL_OP_KEEP)
174
                .compareOp(VK_COMPARE_OP_EQUAL)
175
                .compareMask(0xFF)
176
                .writeMask(writeMask)
177
                .reference(VulkanRenderStateBridge.dynamicStencilReference());
178
        state.back().set(state.front());
179
    }
180
}
181
WaterFogEnvironmentMixinsrc/main/java/combatant/client/mixins/WaterFogEnvironmentMixin.javaJava · 52 lines · 1.9 KB
@Mixin(value = WaterFogEnvironment.class, priority = 1200)priority 1200
WaterFogEnvironmentMixin.javaJava · 52 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import net.minecraft.client.Camera;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.multiplayer.ClientLevel;
13
import net.minecraft.client.renderer.fog.FogData;
14
import net.minecraft.client.renderer.fog.environment.WaterFogEnvironment;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.visuals.WorldTweaks;
21
22
@Mixin(value = WaterFogEnvironment.class, priority = 1200)
23
public class WaterFogEnvironmentMixin {
24
25
    @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
26
    private void combatant$noWaterFog(FogData data,
27
                                      Camera camera,
28
                                      ClientLevel world,
29
                                      float viewDistance,
30
                                      DeltaTracker tickCounter,
31
                                      CallbackInfo ci) {
32
        WorldTweaks module = Modules.get(WorldTweaks.class);
33
        if (module == null || !module.isFogControlEnabled()) return;
34
        if (module.isFogModifyEnabled()) {
35
            module.applyFogOverride(data);
36
            ci.cancel();
37
            return;
38
        }
39
        if (!module.disableWaterFog()) return;
40
41
        float far = Math.max(viewDistance, 16.0f);
42
        data.environmentalStart = far;
43
        data.environmentalEnd = far;
44
        data.renderDistanceStart = far;
45
        data.renderDistanceEnd = far;
46
        data.skyEnd = far;
47
        data.cloudEnd = far;
48
        ci.cancel();
49
    }
50
}
51
52
WeatherEffectRendererMixinsrc/main/java/combatant/client/mixins/WeatherEffectRendererMixin.javaJava · 30 lines · 1.1 KB
@Mixin(value = WeatherEffectRenderer.class, priority = 1200)priority 1200
WeatherEffectRendererMixin.javaJava · 30 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins;
9
10
import combatant.client.features.module.Modules;
11
import combatant.client.features.module.modules.visuals.NoRender;
12
import net.minecraft.client.renderer.WeatherEffectRenderer;
13
import net.minecraft.client.renderer.state.level.WeatherRenderState;
14
import net.minecraft.world.phys.Vec3;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
20
@Mixin(value = WeatherEffectRenderer.class, priority = 1200)
21
public abstract class WeatherEffectRendererMixin {
22
    @Inject(method = "render", at = @At("HEAD"), cancellable = true)
23
    private void combatant$noRenderWeather(Vec3 cameraPos, WeatherRenderState state, CallbackInfo ci) {
24
        NoRender noRender = Modules.get(NoRender.class);
25
        if (noRender != null && noRender.offWorld("weather")) {
26
            ci.cancel();
27
        }
28
    }
29
}
30
BiomeAccessorsrc/main/java/combatant/client/mixins/accessors/BiomeAccessor.javaJava · 20 lines · 629 B
@Mixin(Biome.class)
ModifiesBiome
BiomeAccessor.javaJava · 20 lines · 629 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
package combatant.client.mixins.accessors;
8
9
import net.minecraft.core.BlockPos;
10
import net.minecraft.world.level.biome.Biome;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Invoker;
13
14
/** Exact access to the biome climate record; used only to expose data Minecraft already owns. */
15
@Mixin(Biome.class)
16
public interface BiomeAccessor {
17
    @Invoker("getTemperature")
18
    float combatant$getLocalTemperature(BlockPos pos, int seaLevel);
19
}
20
BiomeClimateSettingsAccessorsrc/main/java/combatant/client/mixins/accessors/BiomeClimateSettingsAccessor.javaJava · 18 lines · 565 B
@Mixin(targets = "net.minecraft.world.level.biome.Biome$ClimateSettings")
BiomeClimateSettingsAccessor.javaJava · 18 lines · 565 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
package combatant.client.mixins.accessors;
8
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.gen.Accessor;
11
12
/** Accessor for Biome.ClimateSettings.downfall, which has no public 26.2 getter. */
13
@Mixin(targets = "net.minecraft.world.level.biome.Biome$ClimateSettings")
14
public interface BiomeClimateSettingsAccessor {
15
    @Accessor("downfall")
16
    float combatant$getDownfall();
17
}
18
BossHealthOverlayAccessorsrc/main/java/combatant/client/mixins/accessors/BossHealthOverlayAccessor.javaJava · 25 lines · 613 B
@Mixin(BossHealthOverlay.class)
BossHealthOverlayAccessor.javaJava · 25 lines · 613 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.BossHealthOverlay;
11
import net.minecraft.client.gui.components.LerpingBossEvent;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
import java.util.Map;
16
import java.util.UUID;
17
18
@Mixin(BossHealthOverlay.class)
19
public interface BossHealthOverlayAccessor {
20
    @Accessor("events")
21
    Map<UUID, LerpingBossEvent> getBars();
22
}
23
24
25
ChatInputSuggestorAccessorsrc/main/java/combatant/client/mixins/accessors/ChatInputSuggestorAccessor.javaJava · 27 lines · 740 B
@Mixin(CommandSuggestions.class)
ChatInputSuggestorAccessor.javaJava · 27 lines · 740 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.brigadier.suggestion.Suggestions;
11
import net.minecraft.client.gui.components.CommandSuggestions;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
import java.util.concurrent.CompletableFuture;
16
17
@Mixin(CommandSuggestions.class)
18
public interface ChatInputSuggestorAccessor {
19
    @Accessor("suggestions")
20
    CommandSuggestions.SuggestionsList getCombatant$window();
21
22
    @Accessor("pendingSuggestions")
23
    CompletableFuture<Suggestions> getCombatant$pendingSuggestions();
24
}
25
26
27
ChatScreenAccessorsrc/main/java/combatant/client/mixins/accessors/ChatScreenAccessor.javaJava · 22 lines · 518 B
@Mixin(ChatScreen.class)
ModifiesChatScreen
ChatScreenAccessor.javaJava · 22 lines · 518 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.EditBox;
11
import net.minecraft.client.gui.screens.ChatScreen;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(ChatScreen.class)
16
public interface ChatScreenAccessor {
17
    @Accessor("input")
18
    EditBox getChatField();
19
}
20
21
22
ChatScreenSuggestorAccessorsrc/main/java/combatant/client/mixins/accessors/ChatScreenSuggestorAccessor.javaJava · 22 lines · 572 B
@Mixin(ChatScreen.class)
ModifiesChatScreen
ChatScreenSuggestorAccessor.javaJava · 22 lines · 572 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.CommandSuggestions;
11
import net.minecraft.client.gui.screens.ChatScreen;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(ChatScreen.class)
16
public interface ChatScreenSuggestorAccessor {
17
    @Accessor("commandSuggestions")
18
    CommandSuggestions getCombatant$suggestor();
19
}
20
21
22
ClientLevelAccessorsrc/main/java/combatant/client/mixins/accessors/ClientLevelAccessor.javaJava · 30 lines · 962 B
@Mixin(ClientLevel.class)
ModifiesClientLevel
ClientLevelAccessor.javaJava · 30 lines · 962 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.multiplayer.ClientLevel;
11
import net.minecraft.client.multiplayer.prediction.BlockStatePredictionHandler;
12
import net.minecraft.core.particles.ParticleOptions;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(ClientLevel.class)
17
public interface ClientLevelAccessor {
18
    @Invoker("doAddParticle")
19
    void invokeAddParticle(ParticleOptions effect,
20
                           boolean force,
21
                           boolean canSpawnOnMinimal,
22
                           double x, double y, double z,
23
                           double vx, double vy, double vz);
24
25
    @Invoker("getBlockStatePredictionHandler")
26
    BlockStatePredictionHandler combatant$getPendingUpdateManager();
27
}
28
29
30
ClientTextTooltipAccessorsrc/main/java/combatant/client/mixins/accessors/ClientTextTooltipAccessor.javaJava · 20 lines · 570 B
@Mixin(ClientTextTooltip.class)
ClientTextTooltipAccessor.javaJava · 20 lines · 570 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTextTooltip;
11
import net.minecraft.util.FormattedCharSequence;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(ClientTextTooltip.class)
16
public interface ClientTextTooltipAccessor {
17
    @Accessor("text")
18
    FormattedCharSequence combatant$getText();
19
}
20
ClientboundExplodePacketAccessorsrc/main/java/combatant/client/mixins/accessors/ClientboundExplodePacketAccessor.javaJava · 25 lines · 686 B
@Mixin(ClientboundExplodePacket.class)
ClientboundExplodePacketAccessor.javaJava · 25 lines · 686 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
11
import net.minecraft.world.phys.Vec3;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Mutable;
14
import org.spongepowered.asm.mixin.gen.Accessor;
15
16
import java.util.Optional;
17
18
@Mixin(ClientboundExplodePacket.class)
19
public interface ClientboundExplodePacketAccessor {
20
21
    @Mutable
22
    @Accessor("playerKnockback")
23
    void combatant$setPlayerKnockback(Optional<Vec3> playerKnockback);
24
}
25
ClientboundSetEntityMotionPacketAccessorsrc/main/java/combatant/client/mixins/accessors/ClientboundSetEntityMotionPacketAccessor.javaJava · 28 lines · 917 B
@Mixin(ClientboundSetEntityMotionPacket.class)
ClientboundSetEntityMotionPacketAccessor.javaJava · 28 lines · 917 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on, adapted from, or implemented
6
 * with reference to Meteor Client
7
 * (https://github.com/MeteorDevelopment/meteor-client).
8
 * Copyright (c) Meteor Development.
9
 *
10
 * Licensed under the GNU General Public License v3.0.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins.accessors;
15
16
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
17
import net.minecraft.world.phys.Vec3;
18
import org.spongepowered.asm.mixin.Mixin;
19
import org.spongepowered.asm.mixin.Mutable;
20
import org.spongepowered.asm.mixin.gen.Accessor;
21
22
@Mixin(ClientboundSetEntityMotionPacket.class)
23
public interface ClientboundSetEntityMotionPacketAccessor {
24
25
    @Mutable
26
    @Accessor("movement")
27
    void combatant$setVelocity(Vec3 velocity);
28
}
CyclingButtonWidgetAccessorsrc/main/java/combatant/client/mixins/accessors/CyclingButtonWidgetAccessor.javaJava · 29 lines · 759 B
@Mixin(CycleButton.class)
ModifiesCycleButton
CyclingButtonWidgetAccessor.javaJava · 29 lines · 759 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.CycleButton;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
import java.util.function.Function;
15
16
@Mixin(CycleButton.class)
17
public interface CyclingButtonWidgetAccessor<T> {
18
    @Accessor("spriteSupplier")
19
    CycleButton.SpriteSupplier<T> combatant$getIcon();
20
21
    @Accessor("displayState")
22
    CycleButton.DisplayState combatant$getLabelType();
23
24
    @Accessor("valueStringifier")
25
    Function<T, net.minecraft.network.chat.Component> combatant$getValueToText();
26
}
27
28
29
EffectParticleEffectAccessorsrc/main/java/combatant/client/mixins/accessors/EffectParticleEffectAccessor.javaJava · 21 lines · 492 B
@Mixin(SpellParticleOption.class)
EffectParticleEffectAccessor.javaJava · 21 lines · 492 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.core.particles.SpellParticleOption;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(SpellParticleOption.class)
15
public interface EffectParticleEffectAccessor {
16
    @Accessor("color")
17
    int combatant$getColor();
18
}
19
20
21
EntityAccessorsrc/main/java/combatant/client/mixins/accessors/EntityAccessor.javaJava · 31 lines · 779 B
@Mixin(Entity.class)
ModifiesEntity
EntityAccessor.javaJava · 31 lines · 779 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.entity.Entity;
11
import net.minecraft.world.entity.PortalProcessor;
12
import net.minecraft.world.phys.Vec3;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Accessor;
15
import org.spongepowered.asm.mixin.gen.Invoker;
16
17
@Mixin(Entity.class)
18
public interface EntityAccessor {
19
20
    @Accessor("portalProcess")
21
    PortalProcessor combatant$getPortalManager();
22
23
    @Accessor("stuckSpeedMultiplier")
24
    void combatant$setMovementMultiplier(Vec3 multiplier);
25
26
    @Invoker("unsetRemoved")
27
    void combatant$unsetRemoved();
28
}
29
30
31
EntityInvokersrc/main/java/combatant/client/mixins/accessors/EntityInvoker.javaJava · 23 lines · 601 B
@Mixin(Entity.class)
ModifiesEntity
EntityInvoker.javaJava · 23 lines · 601 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.entity.Entity;
11
import net.minecraft.world.phys.Vec3;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Invoker;
14
15
@Mixin(Entity.class)
16
public interface EntityInvoker {
17
18
    @Invoker("getInputVector")
19
    static Vec3 combatant$movementInputToVelocity(Vec3 movementInput, float speed, float yaw) {
20
        throw new AssertionError();
21
    }
22
}
23
EntityRenderManagerAccessorsrc/main/java/combatant/client/mixins/accessors/EntityRenderManagerAccessor.javaJava · 34 lines · 1.3 KB
@Mixin(EntityRenderDispatcher.class)
EntityRenderManagerAccessor.javaJava · 34 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import net.minecraft.client.renderer.SubmitNodeCollector;
12
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
13
import net.minecraft.client.renderer.entity.EntityRenderer;
14
import net.minecraft.client.renderer.entity.state.EntityRenderState;
15
import net.minecraft.client.renderer.state.level.CameraRenderState;
16
import net.minecraft.world.entity.Entity;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.gen.Invoker;
19
20
@Mixin(EntityRenderDispatcher.class)
21
public interface EntityRenderManagerAccessor {
22
    @Invoker("getRenderer")
23
    EntityRenderer<?, ?> combatant$invokeGetRenderer(Entity entity);
24
25
    @Invoker("submit")
26
    void combatant$invokeRender(EntityRenderState renderState,
27
                                CameraRenderState cameraState,
28
                                double offsetX,
29
                                double offsetY,
30
                                double offsetZ,
31
                                PoseStack matrices,
32
                                SubmitNodeCollector queue);
33
}
34
EntityRendererAccessorsrc/main/java/combatant/client/mixins/accessors/EntityRendererAccessor.javaJava · 24 lines · 772 B
@Mixin(EntityRenderer.class)
EntityRendererAccessor.javaJava · 24 lines · 772 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.entity.EntityRenderer;
11
import net.minecraft.client.renderer.entity.state.EntityRenderState;
12
import net.minecraft.world.entity.Entity;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(EntityRenderer.class)
17
public interface EntityRendererAccessor {
18
    @Invoker("createRenderState")
19
    EntityRenderState combatant$invokeCreateRenderState();
20
21
    @Invoker("extractRenderState")
22
    void combatant$invokeUpdateRenderState(Entity entity, EntityRenderState state, float tickProgress);
23
}
24
FireworksComponentAccessorsrc/main/java/combatant/client/mixins/accessors/FireworksComponentAccessor.javaJava · 21 lines · 494 B
@Mixin(Fireworks.class)
ModifiesFireworks
FireworksComponentAccessor.javaJava · 21 lines · 494 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.item.component.Fireworks;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(Fireworks.class)
15
public interface FireworksComponentAccessor {
16
    @Accessor("flightDuration")
17
    int combatant$getFlightDuration();
18
}
19
20
21
GameRendererAccessorsrc/main/java/combatant/client/mixins/accessors/GameRendererAccessor.javaJava · 56 lines · 1.8 KB
@Mixin(GameRenderer.class)
ModifiesGameRenderer
GameRendererAccessor.javaJava · 56 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import com.mojang.blaze3d.pipeline.RenderTarget;
12
import net.minecraft.client.gui.render.GuiRenderer;
13
import net.minecraft.client.renderer.GameRenderer;
14
import net.minecraft.client.renderer.SubmitNodeStorage;
15
import net.minecraft.client.renderer.fog.FogRenderer;
16
import net.minecraft.client.renderer.state.GameRenderState;
17
import net.minecraft.client.renderer.state.level.CameraRenderState;
18
import org.joml.Matrix4fc;
19
import org.spongepowered.asm.mixin.Mixin;
20
import org.spongepowered.asm.mixin.gen.Accessor;
21
import org.spongepowered.asm.mixin.gen.Invoker;
22
23
@Mixin(GameRenderer.class)
24
public interface GameRendererAccessor {
25
26
    @Invoker("bobHurt")
27
    void invokeTiltViewWhenHurt(CameraRenderState cameraRenderState, PoseStack matrices);
28
29
    @Invoker("bobView")
30
    void invokeBobView(CameraRenderState cameraRenderState, PoseStack matrices);
31
32
    @Invoker("renderItemInHand")
33
    void invokeRenderHand(CameraRenderState cameraRenderState, float tickDelta, Matrix4fc positionMatrix);
34
35
    @Accessor("gameRenderState")
36
    GameRenderState combatant$getGameRenderState();
37
38
    @Accessor("handAndScreenSubmitNodeStorage")
39
    SubmitNodeStorage combatant$getHandAndScreenSubmitNodeStorage();
40
41
    @Accessor("mainRenderTarget")
42
    RenderTarget combatant$getMainRenderTargetRaw();
43
44
    @Accessor("guiRenderer")
45
    GuiRenderer combatant$getGuiRenderer();
46
47
    @Accessor("fogRenderer")
48
    FogRenderer combatant$getFogRenderer();
49
50
    @Accessor("spinningEffectTime")
51
    float combatant$getNauseaEffectTime();
52
53
    @Accessor("spinningEffectSpeed")
54
    float combatant$getNauseaEffectSpeed();
55
}
56
GlTextureInvokersrc/main/java/combatant/client/mixins/accessors/GlTextureInvoker.javaJava · 33 lines · 1.0 KB
@Mixin(GlTexture.class)
ModifiesGlTexture
GlTextureInvoker.javaJava · 33 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.GpuFormat;
11
import com.mojang.blaze3d.opengl.FrameBufferCache;
12
import com.mojang.blaze3d.opengl.GlTexture;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(GlTexture.class)
17
public interface GlTextureInvoker {
18
    @Invoker("<init>")
19
    static GlTexture combatant$create(int usage,
20
                                      String label,
21
                                      GpuFormat format,
22
                                      int width,
23
                                      int height,
24
                                      int depthOrLayers,
25
                                      int mipLevels,
26
                                      int glId,
27
                                      FrameBufferCache frameBufferCache) {
28
        throw new AssertionError();
29
    }
30
}
31
32
33
GpuDeviceAccessorsrc/main/java/combatant/client/mixins/accessors/GpuDeviceAccessor.javaJava · 20 lines · 526 B
@Mixin(GpuDevice.class)
ModifiesGpuDevice
GpuDeviceAccessor.javaJava · 20 lines · 526 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.systems.GpuDevice;
11
import com.mojang.blaze3d.systems.GpuDeviceBackend;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(GpuDevice.class)
16
public interface GpuDeviceAccessor {
17
    @Accessor("backend")
18
    GpuDeviceBackend combatant$getBackend();
19
}
20
InGameOverlayRendererAccessorsrc/main/java/combatant/client/mixins/accessors/InGameOverlayRendererAccessor.javaJava · 37 lines · 1.2 KB
@Mixin(ScreenEffectRenderer.class)
InGameOverlayRendererAccessor.javaJava · 37 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import net.minecraft.client.renderer.ScreenEffectRenderer;
12
import net.minecraft.client.renderer.SubmitNodeCollector;
13
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.gen.Invoker;
16
17
@Mixin(ScreenEffectRenderer.class)
18
public interface InGameOverlayRendererAccessor {
19
20
    @Invoker("submitFire")
21
    static void callRenderFireOverlay(PoseStack matrices,
22
                                      SubmitNodeCollector vertexConsumers,
23
                                      TextureAtlasSprite sprite) {
24
        throw new AssertionError();
25
    }
26
27
    @Invoker("submitBlockSprite")
28
    static void callRenderInWallOverlay(TextureAtlasSprite sprite,
29
                                        PoseStack matrices,
30
                                        SubmitNodeCollector vertexConsumers,
31
                                        int color) {
32
        throw new AssertionError();
33
    }
34
}
35
36
37
InputAccessorsrc/main/java/combatant/client/mixins/accessors/InputAccessor.javaJava · 27 lines · 627 B
@Mixin(ClientInput.class)
ModifiesClientInput
InputAccessor.javaJava · 27 lines · 627 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.player.ClientInput;
11
import net.minecraft.world.entity.player.Input;
12
import net.minecraft.world.phys.Vec2;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Accessor;
15
16
@Mixin(ClientInput.class)
17
public interface InputAccessor {
18
19
    @Accessor("moveVector")
20
    void setMovementVector(Vec2 vec);
21
22
    @Accessor("keyPresses")
23
    void setPlayerInput(Input input);
24
}
25
26
27
ItemCooldownEntryAccessorsrc/main/java/combatant/client/mixins/accessors/ItemCooldownEntryAccessor.javaJava · 18 lines · 466 B
@Mixin(targets = "net.minecraft.world.item.ItemCooldowns$CooldownInstance")
ItemCooldownEntryAccessor.javaJava · 18 lines · 466 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.gen.Accessor;
12
13
@Mixin(targets = "net.minecraft.world.item.ItemCooldowns$CooldownInstance")
14
public interface ItemCooldownEntryAccessor {
15
    @Accessor("endTime")
16
    int getEndTick();
17
}
18
ItemCooldownManagerAccessorsrc/main/java/combatant/client/mixins/accessors/ItemCooldownManagerAccessor.javaJava · 27 lines · 604 B
@Mixin(ItemCooldowns.class)
ItemCooldownManagerAccessor.javaJava · 27 lines · 604 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.resources.Identifier;
11
import net.minecraft.world.item.ItemCooldowns;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
import java.util.Map;
16
17
@Mixin(ItemCooldowns.class)
18
public interface ItemCooldownManagerAccessor {
19
    @Accessor("cooldowns")
20
    Map<Identifier, Object> getEntries();
21
22
    @Accessor("tickCount")
23
    int getTick();
24
}
25
26
27
ItemRenderStateLayerAccessorsrc/main/java/combatant/client/mixins/accessors/ItemRenderStateLayerAccessor.javaJava · 46 lines · 1.2 KB
@Mixin(ItemStackRenderState.LayerRenderState.class)not in mixin config
ItemRenderStateLayerAccessor.javaJava · 46 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.item.ItemStackRenderState;
11
import net.minecraft.client.renderer.rendertype.RenderType;
12
import net.minecraft.client.renderer.special.SpecialModelRenderer;
13
import net.minecraft.client.resources.model.cuboid.ItemTransform;
14
import net.minecraft.client.resources.model.geometry.BakedQuad;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.gen.Accessor;
17
18
import java.util.List;
19
20
@Mixin(ItemStackRenderState.LayerRenderState.class)
21
public interface ItemRenderStateLayerAccessor {
22
23
    @Accessor("renderType")
24
    RenderType pvs$getRenderLayer();
25
26
    @Accessor("quads")
27
    List<BakedQuad> pvs$getQuads();
28
29
    @Accessor("tintLayers")
30
    int[] pvs$getTints();
31
32
    @Accessor("foilType")
33
    ItemStackRenderState.FoilType pvs$getGlint();
34
35
    @Accessor("transform")
36
    ItemTransform pvs$getTransform();
37
38
    @Accessor("specialRenderer")
39
    SpecialModelRenderer<Object> pvs$getSpecialModelType();
40
41
    @Accessor("argumentForSpecialRendering")
42
    Object pvs$getData();
43
}
44
45
46
LevelExtractorAccessorsrc/main/java/combatant/client/mixins/accessors/LevelExtractorAccessor.javaJava · 22 lines · 656 B
@Mixin(LevelExtractor.class)
LevelExtractorAccessor.javaJava · 22 lines · 656 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.entity.state.EntityRenderState;
11
import net.minecraft.client.renderer.extract.LevelExtractor;
12
import net.minecraft.world.entity.Entity;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(LevelExtractor.class)
17
public interface LevelExtractorAccessor {
18
19
    @Invoker("extractEntity")
20
    EntityRenderState combatant$invokeExtractEntity(Entity entity, float tickDelta);
21
}
22
LevelRendererAccessorsrc/main/java/combatant/client/mixins/accessors/LevelRendererAccessor.javaJava · 51 lines · 1.6 KB
@Mixin(LevelRenderer.class)
LevelRendererAccessor.javaJava · 51 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.textures.GpuSampler;
11
import net.minecraft.client.renderer.*;
12
import net.minecraft.client.renderer.feature.FeatureRenderDispatcher;
13
import net.minecraft.client.renderer.state.level.LevelRenderState;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.gen.Accessor;
16
import org.spongepowered.asm.mixin.gen.Invoker;
17
18
@Mixin(LevelRenderer.class)
19
public interface LevelRendererAccessor {
20
21
    @Accessor("levelRenderState")
22
    LevelRenderState combatant$getWorldRenderState();
23
24
    @Accessor("skyRenderer")
25
    SkyRenderer combatant$getSkyRendering();
26
27
    @Accessor("submitNodeStorage")
28
    SubmitNodeStorage combatant$getEntityRenderCommandQueue();
29
30
    @Accessor("featureRenderDispatcher")
31
    FeatureRenderDispatcher combatant$getEntityRenderDispatcher();
32
33
    @Accessor("renderBuffers")
34
    RenderBuffers combatant$getRenderBuffers();
35
36
    @Accessor("renderBuffers")
37
    void combatant$setRenderBuffers(RenderBuffers renderBuffers);
38
39
    @Accessor("chunkLayerSampler")
40
    GpuSampler combatant$getTerrainSampler();
41
42
    @Accessor("chunkLayerSampler")
43
    void combatant$setTerrainSampler(GpuSampler terrainSampler);
44
45
    @Invoker("submitEntities")
46
    void combatant$invokeSubmitEntities(com.mojang.blaze3d.vertex.PoseStack poseStack,
47
                                        LevelRenderState levelRenderState,
48
                                        SubmitNodeCollector collector);
49
50
}
51
LivingEntityAccessorsrc/main/java/combatant/client/mixins/accessors/LivingEntityAccessor.javaJava · 27 lines · 893 B
@Mixin(LivingEntity.class)
ModifiesLivingEntity
LivingEntityAccessor.javaJava · 27 lines · 893 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.entity.LivingEntity;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
// Это новый Mixin для доступа к полю или методу, который управляет временем последней атаки
15
@Mixin(LivingEntity.class)
16
public interface LivingEntityAccessor {
17
18
    // Пример использования нового поля или метода, если оно называется ticksSinceLastAttack
19
    @Accessor("attackStrengthTicker")
20
    void setTicksSinceLastAttack(int ticks);
21
22
    @Accessor("noJumpDelay")
23
    void combatant$setJumpingCooldown(int cooldown);
24
}
25
26
27
LivingEntityRenderStateAccessorsrc/main/java/combatant/client/mixins/accessors/LivingEntityRenderStateAccessor.javaJava · 26 lines · 684 B
@Mixin(LivingEntityRenderState.class)
LivingEntityRenderStateAccessor.javaJava · 26 lines · 684 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(LivingEntityRenderState.class)
15
public interface LivingEntityRenderStateAccessor {
16
17
    @Accessor("bodyRot")
18
    void combatant$setBodyYaw(float bodyYaw);
19
20
    @Accessor("yRot")
21
    void combatant$setRelativeHeadYaw(float relativeHeadYaw);
22
23
    @Accessor("xRot")
24
    void combatant$setPitch(float pitch);
25
}
26
LocalPlayerAccessorsrc/main/java/combatant/client/mixins/accessors/LocalPlayerAccessor.javaJava · 51 lines · 1.3 KB
@Mixin(LocalPlayer.class)
ModifiesLocalPlayer
LocalPlayerAccessor.javaJava · 51 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.player.LocalPlayer;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(LocalPlayer.class)
17
public interface LocalPlayerAccessor {
18
19
    @Accessor("minecraft")
20
    Minecraft getClient();
21
22
    @Accessor("portalEffectIntensity")
23
    float combatant$getNauseaIntensity();
24
25
    @Accessor("portalEffectIntensity")
26
    void combatant$setNauseaIntensity(float value);
27
28
    @Accessor("oPortalEffectIntensity")
29
    float combatant$getLastNauseaIntensity();
30
31
    @Accessor("oPortalEffectIntensity")
32
    void combatant$setLastNauseaIntensity(float value);
33
34
    @Accessor("positionReminder")
35
    void combatant$setTicksSinceLastPositionPacketSent(int ticks);
36
37
    @Accessor("wasSprinting")
38
    void combatant$setLastSprinting(boolean sprinting);
39
40
    @Invoker("canStartSprinting")
41
    boolean combatant$canStartSprinting();
42
43
    @Invoker("shouldStopRunSprinting")
44
    boolean combatant$shouldStopSprinting();
45
46
    @Invoker("shouldStopSwimSprinting")
47
    boolean combatant$shouldStopSwimSprinting();
48
}
49
50
51
MinecraftAccessorsrc/main/java/combatant/client/mixins/accessors/MinecraftAccessor.javaJava · 87 lines · 2.9 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
MinecraftAccessor.javaJava · 87 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.authlib.minecraft.UserApiService;
11
import com.mojang.authlib.yggdrasil.FriendsService;
12
import com.mojang.authlib.yggdrasil.ProfileResult;
13
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
14
import net.minecraft.client.Minecraft;
15
import net.minecraft.client.User;
16
import net.minecraft.client.gui.screens.social.PlayerSocialManager;
17
import net.minecraft.client.gui.screens.social.RemoteFriendListUpdateHandler;
18
import net.minecraft.client.main.GameConfig;
19
import net.minecraft.client.multiplayer.ProfileKeyPairManager;
20
import net.minecraft.client.multiplayer.chat.report.ReportingContext;
21
import net.minecraft.client.telemetry.ClientTelemetryManager;
22
import net.minecraft.server.Services;
23
import org.spongepowered.asm.mixin.Mixin;
24
import org.spongepowered.asm.mixin.Mutable;
25
import org.spongepowered.asm.mixin.gen.Accessor;
26
import org.spongepowered.asm.mixin.gen.Invoker;
27
28
import java.util.concurrent.CompletableFuture;
29
30
@Mixin(Minecraft.class)
31
public interface MinecraftAccessor {
32
33
    @Accessor("rightClickDelay")
34
    int combatant$getItemUseCooldown();
35
36
    @Accessor("rightClickDelay")
37
    void combatant$setItemUseCooldown(int itemUseCooldown);
38
39
    @Mutable
40
    @Accessor("user")
41
    void combatant$setSession(User session);
42
43
    @Mutable
44
    @Accessor("services")
45
    void combatant$setServices(Services services);
46
47
    @Mutable
48
    @Accessor("profileFuture")
49
    void combatant$setProfileFuture(CompletableFuture<ProfileResult> profileFuture);
50
51
    @Mutable
52
    @Accessor("userApiService")
53
    void combatant$setUserApiService(UserApiService userApiService);
54
55
    @Mutable
56
    @Accessor("userPropertiesFuture")
57
    void combatant$setUserPropertiesFuture(CompletableFuture<UserApiService.UserProperties> userPropertiesFuture);
58
59
    @Mutable
60
    @Accessor("playerSocialManager")
61
    void combatant$setPlayerSocialManager(PlayerSocialManager playerSocialManager);
62
63
    @Accessor("remoteFriendListUpdateHandler")
64
    RemoteFriendListUpdateHandler combatant$getRemoteFriendListUpdateHandler();
65
66
    @Mutable
67
    @Accessor("remoteFriendListUpdateHandler")
68
    void combatant$setRemoteFriendListUpdateHandler(RemoteFriendListUpdateHandler remoteFriendListUpdateHandler);
69
70
    @Mutable
71
    @Accessor("telemetryManager")
72
    void combatant$setTelemetryManager(ClientTelemetryManager telemetryManager);
73
74
    @Mutable
75
    @Accessor("profileKeyPairManager")
76
    void combatant$setProfileKeyPairManager(ProfileKeyPairManager profileKeyPairManager);
77
78
    @Mutable
79
    @Accessor("reportingContext")
80
    void combatant$setReportingContext(ReportingContext reportingContext);
81
82
    @Invoker("createUserApiService")
83
    static UserApiService combatant$createUserApiService(YggdrasilAuthenticationService service, GameConfig config) {
84
        throw new AssertionError();
85
    }
86
}
87
ModelPartAccessorsrc/main/java/combatant/client/mixins/accessors/ModelPartAccessor.javaJava · 21 lines · 503 B
@Mixin(ModelPart.class)
ModifiesModelPart
ModelPartAccessor.javaJava · 21 lines · 503 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.model.geom.ModelPart;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
import java.util.List;
15
16
@Mixin(ModelPart.class)
17
public interface ModelPartAccessor {
18
    @Accessor("cubes")
19
    List<ModelPart.Cube> combatant$getCubes();
20
}
21
MultiPlayerGameModeAccessorsrc/main/java/combatant/client/mixins/accessors/MultiPlayerGameModeAccessor.javaJava · 43 lines · 1.2 KB
@Mixin(MultiPlayerGameMode.class)
MultiPlayerGameModeAccessor.javaJava · 43 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
11
import net.minecraft.core.BlockPos;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
import org.spongepowered.asm.mixin.gen.Invoker;
15
16
@Mixin(MultiPlayerGameMode.class)
17
public interface MultiPlayerGameModeAccessor {
18
19
    @Accessor("destroyBlockPos")
20
    BlockPos combatant$getCurrentBreakingPos();
21
22
    @Accessor("destroyProgress")
23
    float combatant$getCurrentBreakingProgress();
24
25
    @Accessor("destroyProgress")
26
    void combatant$setCurrentBreakingProgress(float progress);
27
28
    @Accessor("destroyDelay")
29
    int combatant$getBlockBreakingCooldown();
30
31
    @Accessor("destroyDelay")
32
    void combatant$setBlockBreakingCooldown(int cooldown);
33
34
    @Accessor("carriedIndex")
35
    int combatant$getLastSelectedSlot();
36
37
    @Accessor("carriedIndex")
38
    void combatant$setLastSelectedSlot(int slot);
39
40
    @Invoker("ensureHasSentCarriedItem")
41
    void combatant$syncSelectedSlot();
42
}
43
PersistentProjectileEntityAccessorsrc/main/java/combatant/client/mixins/accessors/PersistentProjectileEntityAccessor.javaJava · 21 lines · 510 B
@Mixin(AbstractArrow.class)
PersistentProjectileEntityAccessor.javaJava · 21 lines · 510 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.entity.projectile.arrow.AbstractArrow;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Invoker;
13
14
@Mixin(AbstractArrow.class)
15
public interface PersistentProjectileEntityAccessor {
16
    @Invoker("isInGround")
17
    boolean combatant$isInGround();
18
}
19
20
21
PlayerInventoryAccessorsrc/main/java/combatant/client/mixins/accessors/PlayerInventoryAccessor.javaJava · 24 lines · 555 B
@Mixin(Inventory.class)
ModifiesInventory
PlayerInventoryAccessor.javaJava · 24 lines · 555 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.entity.player.Inventory;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(Inventory.class)
15
public interface PlayerInventoryAccessor {
16
    @Accessor("selected")
17
    int combatant$getSelectedSlot();
18
19
    @Accessor("selected")
20
    void combatant$setSelectedSlot(int slot);
21
}
22
23
24
PlayerTabOverlayAccessorsrc/main/java/combatant/client/mixins/accessors/PlayerTabOverlayAccessor.javaJava · 23 lines · 602 B
@Mixin(PlayerTabOverlay.class)
PlayerTabOverlayAccessor.javaJava · 23 lines · 602 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.PlayerTabOverlay;
11
import net.minecraft.network.chat.Component;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(PlayerTabOverlay.class)
16
public interface PlayerTabOverlayAccessor {
17
    @Accessor("header")
18
    Component combatant$getHeader();
19
20
    @Accessor("footer")
21
    Component combatant$getFooter();
22
}
23
RenderLayerInvokerAccessorsrc/main/java/combatant/client/mixins/accessors/RenderLayerInvokerAccessor.javaJava · 25 lines · 620 B
@Mixin(RenderType.class)
ModifiesRenderType
RenderLayerInvokerAccessor.javaJava · 25 lines · 620 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.rendertype.RenderSetup;
11
import net.minecraft.client.renderer.rendertype.RenderType;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Invoker;
14
15
@Mixin(RenderType.class)
16
public interface RenderLayerInvokerAccessor {
17
18
    @Invoker("create")
19
    static RenderType callOf(String name, RenderSetup setup) {
20
        throw new AssertionError();
21
    }
22
}
23
24
25
ServerboundInteractPacketAccessorsrc/main/java/combatant/client/mixins/accessors/ServerboundInteractPacketAccessor.javaJava · 19 lines · 520 B
@Mixin(ServerboundInteractPacket.class)
ServerboundInteractPacketAccessor.javaJava · 19 lines · 520 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(ServerboundInteractPacket.class)
15
public interface ServerboundInteractPacketAccessor {
16
    @Accessor("entityId")
17
    int combatant$getEntityId();
18
}
19
ServerboundMovePlayerPacketAccessorsrc/main/java/combatant/client/mixins/accessors/ServerboundMovePlayerPacketAccessor.javaJava · 39 lines · 1.0 KB
@Mixin(ServerboundMovePlayerPacket.class)
ServerboundMovePlayerPacketAccessor.javaJava · 39 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on, adapted from, or implemented
6
 * with reference to Meteor Client
7
 * (https://github.com/MeteorDevelopment/meteor-client).
8
 * Copyright (c) Meteor Development.
9
 *
10
 * Licensed under the GNU General Public License v3.0.
11
 * See THIRD_PARTY_NOTICES.md for details.
12
 */
13
14
package combatant.client.mixins.accessors;
15
16
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
17
import org.spongepowered.asm.mixin.Mixin;
18
import org.spongepowered.asm.mixin.Mutable;
19
import org.spongepowered.asm.mixin.gen.Accessor;
20
21
@Mixin(ServerboundMovePlayerPacket.class)
22
public interface ServerboundMovePlayerPacketAccessor {
23
    @Mutable
24
    @Accessor("x")
25
    void combatant$setX(double x);
26
27
    @Mutable
28
    @Accessor("y")
29
    void combatant$setY(double y);
30
31
    @Mutable
32
    @Accessor("z")
33
    void combatant$setZ(double z);
34
35
    @Mutable
36
    @Accessor("onGround")
37
    void combatant$setOnGround(boolean onGround);
38
}
39
ShaderLoaderDefinitionsAccessorsrc/main/java/combatant/client/mixins/accessors/ShaderLoaderDefinitionsAccessor.javaJava · 26 lines · 730 B
@Mixin(ShaderManager.Configs.class)
ShaderLoaderDefinitionsAccessor.javaJava · 26 lines · 730 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.PostChainConfig;
11
import net.minecraft.client.renderer.ShaderManager;
12
import net.minecraft.resources.Identifier;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.gen.Accessor;
15
16
import java.util.Map;
17
18
@Mixin(ShaderManager.Configs.class)
19
public interface ShaderLoaderDefinitionsAccessor {
20
    @Accessor("shaderSources")
21
    Map<?, String> combatant$getShaderSources();
22
23
    @Accessor("postChains")
24
    Map<Identifier, PostChainConfig> combatant$getPostChains();
25
}
26
ShaderSourceKeyAccessorsrc/main/java/combatant/client/mixins/accessors/ShaderSourceKeyAccessor.javaJava · 23 lines · 623 B
@Mixin(targets = "net.minecraft.client.renderer.ShaderManager$ShaderSourceKey")
ShaderSourceKeyAccessor.javaJava · 23 lines · 623 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import com.mojang.blaze3d.shaders.ShaderType;
11
import net.minecraft.resources.Identifier;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(targets = "net.minecraft.client.renderer.ShaderManager$ShaderSourceKey")
16
public interface ShaderSourceKeyAccessor {
17
    @Accessor("id")
18
    Identifier combatant$getId();
19
20
    @Accessor("type")
21
    ShaderType combatant$getType();
22
}
23
SliderWidgetAccessorsrc/main/java/combatant/client/mixins/accessors/SliderWidgetAccessor.javaJava · 24 lines · 559 B
@Mixin(AbstractSliderButton.class)
SliderWidgetAccessor.javaJava · 24 lines · 559 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.AbstractSliderButton;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(AbstractSliderButton.class)
15
public interface SliderWidgetAccessor {
16
    @Accessor("value")
17
    double combatant$getValue();
18
19
    @Accessor("dragging")
20
    boolean combatant$isDragging();
21
}
22
23
24
SlotAccessorsrc/main/java/combatant/client/mixins/accessors/SlotAccessor.javaJava · 19 lines · 444 B
@Mixin(Slot.class)
ModifiesSlot
SlotAccessor.javaJava · 19 lines · 444 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.inventory.Slot;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(Slot.class)
15
public interface SlotAccessor {
16
    @Accessor("slot")
17
    int combatant$getIndex();
18
}
19
SpriteAnimationStateAccessorsrc/main/java/combatant/client/mixins/accessors/SpriteAnimationStateAccessor.javaJava · 22 lines · 564 B
@Mixin(SpriteContents.AnimationState.class)not in mixin config
SpriteAnimationStateAccessor.javaJava · 22 lines · 564 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.renderer.texture.SpriteContents;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(SpriteContents.AnimationState.class)
15
public interface SpriteAnimationStateAccessor {
16
    @Accessor("frame")
17
    int combatant$getFrame();
18
19
    @Accessor("subFrame")
20
    int combatant$getSubFrame();
21
}
22
SuggestionWindowAccessorsrc/main/java/combatant/client/mixins/accessors/SuggestionWindowAccessor.javaJava · 39 lines · 922 B
@Mixin(CommandSuggestions.SuggestionsList.class)
SuggestionWindowAccessor.javaJava · 39 lines · 922 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.CommandSuggestions;
11
import net.minecraft.client.renderer.Rect2i;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
import java.util.List;
16
17
@Mixin(CommandSuggestions.SuggestionsList.class)
18
public interface SuggestionWindowAccessor {
19
    @Accessor("rect")
20
    Rect2i getCombatant$area();
21
22
    @Accessor("suggestionList")
23
    List<?> getCombatant$suggestions();
24
25
    @Accessor("current")
26
    int getCombatant$selection();
27
28
    @Accessor("current")
29
    void setCombatant$selection(int selection);
30
31
    @Accessor("offset")
32
    int getCombatant$inWindowIndex();
33
34
    @Accessor("offset")
35
    void setCombatant$inWindowIndex(int index);
36
}
37
38
39
TextFieldWidgetAccessorsrc/main/java/combatant/client/mixins/accessors/TextFieldWidgetAccessor.javaJava · 22 lines · 549 B
@Mixin(EditBox.class)
ModifiesEditBox
TextFieldWidgetAccessor.javaJava · 22 lines · 549 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.EditBox;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(EditBox.class)
15
public interface TextFieldWidgetAccessor {
16
    @Accessor("cursorPos")
17
    int combatant$getSelectionStart();
18
19
    @Accessor("highlightPos")
20
    int combatant$getSelectionEnd();
21
}
22
TextIconButtonWidgetAccessorsrc/main/java/combatant/client/mixins/accessors/TextIconButtonWidgetAccessor.javaJava · 28 lines · 700 B
@Mixin(SpriteIconButton.class)
TextIconButtonWidgetAccessor.javaJava · 28 lines · 700 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.client.gui.components.SpriteIconButton;
11
import net.minecraft.client.gui.components.WidgetSprites;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.gen.Accessor;
14
15
@Mixin(SpriteIconButton.class)
16
public interface TextIconButtonWidgetAccessor {
17
    @Accessor("spriteWidth")
18
    int combatant$getTextureWidth();
19
20
    @Accessor("spriteHeight")
21
    int combatant$getTextureHeight();
22
23
    @Accessor("sprite")
24
    WidgetSprites combatant$getTexture();
25
}
26
27
28
WorldAccessorsrc/main/java/combatant/client/mixins/accessors/WorldAccessor.javaJava · 34 lines · 760 B
@Mixin(Level.class)
ModifiesLevel
WorldAccessor.javaJava · 34 lines · 760 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.accessors;
9
10
import net.minecraft.world.level.Level;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
14
@Mixin(Level.class)
15
public interface WorldAccessor {
16
17
    @Accessor("isClientSide")
18
    boolean combatant$isClient();
19
20
    @Accessor("rainLevel")
21
    float combatant$getRainGradientRaw();
22
23
    @Accessor("oRainLevel")
24
    float combatant$getLastRainGradientRaw();
25
26
    @Accessor("thunderLevel")
27
    float combatant$getThunderGradientRaw();
28
29
    @Accessor("oThunderLevel")
30
    float combatant$getLastThunderGradientRaw();
31
}
32
33
34
HmiItemLayerRenderStateMixinsrc/main/java/combatant/client/mixins/hmi_recode/HmiItemLayerRenderStateMixin.javaJava · 48 lines · 2.0 KB
@Mixin(targets = "net.minecraft.client.renderer.item.ItemStackRenderState$LayerRenderState")
HmiItemLayerRenderStateMixin.javaJava · 48 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
/* HoldMyItems Recode; original project by sapling, CC0-1.0. */
9
package combatant.client.mixins.hmi_recode;
10
11
import combatant.client.features.hmi_recode.HoldMyItems;
12
import combatant.client.features.hmi_recode.render.HmiModelCommand;
13
import combatant.client.features.hmi_recode.render.HmiModelQuadList;
14
import net.minecraft.client.resources.model.geometry.BakedQuad;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.ModifyArg;
18
19
import java.util.List;
20
21
@Mixin(targets = "net.minecraft.client.renderer.item.ItemStackRenderState$LayerRenderState")
22
public abstract class HmiItemLayerRenderStateMixin {
23
    /**
24
     * Do not redirect SubmitNodeCollector.submitItem here. Fabric Renderer API redirects the exact
25
     * same invocation to add its extended mesh submit path. Replacing that INVOKE makes whichever
26
     * redirect runs second fail its injection check.
27
     *
28
     * <p>Instead, carry an immutable HMI command snapshot inside the vanilla quad-list argument.
29
     * The invocation itself remains untouched for Fabric Renderer API and other renderer mods.</p>
30
     */
31
    @ModifyArg(
32
            method = "submit",
33
            at = @At(
34
                    value = "INVOKE",
35
                    target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitItem(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemDisplayContext;III[ILjava/util/List;Lnet/minecraft/client/renderer/item/ItemStackRenderState$FoilType;)V"
36
            ),
37
            index = 6
38
    )
39
    private List<BakedQuad> combatant$hmi$attachModelPose(List<BakedQuad> quads) {
40
        if (quads.isEmpty()) return quads;
41
42
        List<HmiModelCommand> commands = HoldMyItems.snapshotModelCommands();
43
        if (commands.isEmpty()) return quads;
44
45
        return new HmiModelQuadList(quads, commands);
46
    }
47
}
48
IrisCommonUniformsMixinsrc/main/java/combatant/client/mixins/iris/IrisCommonUniformsMixin.javaJava · 33 lines · 1.4 KB
@Mixin(targets = "net.irisshaders.iris.uniforms.CommonUniforms", remap = false)remap=false
Modifiesnet.irisshaders.iris.uniforms.CommonUniforms external mod
IrisCommonUniformsMixin.javaJava · 33 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.irisshaders.iris.gl.uniform.UniformHolder;
11
import net.irisshaders.iris.shaderpack.IdMap;
12
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
13
import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.Pseudo;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.render.iris.CombatantIrisUniforms;
20
21
@Pseudo
22
@Mixin(targets = "net.irisshaders.iris.uniforms.CommonUniforms", remap = false)
23
public abstract class IrisCommonUniformsMixin {
24
    @Inject(method = "addNonDynamicUniforms", at = @At("TAIL"), remap = false)
25
    private static void combatant$addCombatantUniforms(UniformHolder uniforms,
26
                                                       IdMap idMap,
27
                                                       PackDirectives packDirectives,
28
                                                       FrameUpdateNotifier updateNotifier,
29
                                                       CallbackInfo ci) {
30
        CombatantIrisUniforms.add(uniforms);
31
    }
32
}
33
IrisGameRendererInteropMixinsrc/main/java/combatant/client/mixins/iris/IrisGameRendererInteropMixin.javaJava · 35 lines · 1.3 KB
@Mixin(value = GameRenderer.class, priority = 900)priority 900
ModifiesGameRenderer
IrisGameRendererInteropMixin.javaJava · 35 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.minecraft.client.DeltaTracker;
11
import net.minecraft.client.renderer.GameRenderer;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.render.iris.IrisCombatantFrameHooks;
17
import combatant.client.render.iris.IrisSecondHandScene;
18
19
@Mixin(value = GameRenderer.class, priority = 900)
20
public abstract class IrisGameRendererInteropMixin {
21
    @Inject(
22
            method = "renderLevel",
23
            at = @At(
24
                    value = "INVOKE",
25
                    target = "Lnet/minecraft/client/renderer/GameRenderer;renderItemInHand(Lnet/minecraft/client/renderer/state/level/CameraRenderState;FLorg/joml/Matrix4fc;)V",
26
                    shift = At.Shift.BEFORE
27
            )
28
    )
29
    private void combatant$renderIrisHandInSecondScene(DeltaTracker tickCounter, CallbackInfo ci) {
30
        IrisSecondHandScene.finalizeWorld();
31
        IrisCombatantFrameHooks.renderAfterIrisFinalization();
32
    }
33
34
}
35
IrisHandRendererAccessorsrc/main/java/combatant/client/mixins/iris/IrisHandRendererAccessor.javaJava · 32 lines · 1.1 KB
@Mixin(value = HandRenderer.class, remap = false)remap=false
ModifiesHandRenderer external mod
IrisHandRendererAccessor.javaJava · 32 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.irisshaders.iris.pathways.HandRenderer;
11
import com.mojang.blaze3d.vertex.PoseStack;
12
import net.minecraft.client.renderer.GameRenderer;
13
import net.minecraft.client.renderer.state.level.CameraRenderState;
14
import org.joml.Matrix4fc;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Pseudo;
17
import org.spongepowered.asm.mixin.gen.Accessor;
18
import org.spongepowered.asm.mixin.gen.Invoker;
19
20
@Pseudo
21
@Mixin(value = HandRenderer.class, remap = false)
22
public interface IrisHandRendererAccessor {
23
    @Accessor(value = "renderingSolid", remap = false)
24
    void combatant$setRenderingSolid(boolean renderingSolid);
25
26
    @Invoker(value = "setupGlState", remap = false)
27
    PoseStack combatant$invokeSetupGlState(GameRenderer renderer,
28
                                           CameraRenderState cameraRenderState,
29
                                           Matrix4fc positionMatrix,
30
                                           float tickDelta);
31
}
32
IrisHandRendererMixinsrc/main/java/combatant/client/mixins/iris/IrisHandRendererMixin.javaJava · 53 lines · 2.4 KB
@Mixin(value = HandRenderer.class, remap = false)remap=false
ModifiesHandRenderer external mod
IrisHandRendererMixin.javaJava · 53 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.irisshaders.iris.pathways.HandRenderer;
11
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
12
import net.minecraft.client.Camera;
13
import net.minecraft.client.renderer.GameRenderer;
14
import net.minecraft.client.renderer.state.level.CameraRenderState;
15
import org.joml.Matrix4fc;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Pseudo;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.render.iris.IrisCompatibilityGuards;
22
import combatant.client.render.iris.IrisSecondHandScene;
23
24
@Pseudo
25
@Mixin(value = HandRenderer.class, remap = false)
26
public abstract class IrisHandRendererMixin {
27
    @Inject(method = "renderSolid", at = @At("HEAD"), cancellable = true, remap = false)
28
    private void combatant$disableIrisSolidHand(Matrix4fc modelMatrix,
29
                                                float tickDelta,
30
                                                Camera camera,
31
                                                CameraRenderState cameraRenderState,
32
                                                GameRenderer gameRenderer,
33
                                                WorldRenderingPipeline pipeline,
34
                                                CallbackInfo ci) {
35
        if (IrisCompatibilityGuards.suppressIrisHandRendering() && !IrisSecondHandScene.isRendering()) {
36
            ci.cancel();
37
        }
38
    }
39
40
    @Inject(method = "renderTranslucent", at = @At("HEAD"), cancellable = true, remap = false)
41
    private void combatant$disableIrisTranslucentHand(Matrix4fc modelMatrix,
42
                                                      float tickDelta,
43
                                                      Camera camera,
44
                                                      CameraRenderState cameraRenderState,
45
                                                      GameRenderer gameRenderer,
46
                                                      WorldRenderingPipeline pipeline,
47
                                                      CallbackInfo ci) {
48
        if (IrisCompatibilityGuards.suppressIrisHandRendering() && !IrisSecondHandScene.isRendering()) {
49
            ci.cancel();
50
        }
51
    }
52
}
53
IrisIncludeProcessorMixinsrc/main/java/combatant/client/mixins/iris/IrisIncludeProcessorMixin.javaJava · 74 lines · 2.8 KB
@Mixin(value = IncludeProcessor.class, remap = false)remap=false
ModifiesIncludeProcessor external mod
IrisIncludeProcessorMixin.javaJava · 74 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import com.google.common.collect.ImmutableList;
11
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
12
import net.irisshaders.iris.Iris;
13
import net.irisshaders.iris.shaderpack.include.AbsolutePackPath;
14
import net.irisshaders.iris.shaderpack.include.IncludeProcessor;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Pseudo;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import combatant.client.render.iris.patch.ShaderPatchEngine;
20
import combatant.client.util.logging.DebugLog;
21
22
import java.util.Objects;
23
24
@Pseudo
25
@Mixin(value = IncludeProcessor.class, remap = false)
26
public abstract class IrisIncludeProcessorMixin {
27
    @Unique
28
    private ShaderPatchEngine.Session combatant$patchSession;
29
    @Unique
30
    private String combatant$patchSessionPackName;
31
32
    @Unique
33
    private static String combatant$currentShaderPackName() {
34
        String loadingPackName = ShaderPatchEngine.loadingShaderPackName();
35
        if (loadingPackName != null && !loadingPackName.isBlank()) {
36
            return loadingPackName;
37
        }
38
        try {
39
            return Iris.getCurrentPackName();
40
        } catch (Throwable throwable) {
41
            DebugLog.warn("[IrisPatch] Unable to query current Iris shaderpack name: %s", throwable.getClass().getSimpleName());
42
            return null;
43
        }
44
    }
45
46
    @ModifyReturnValue(method = "getIncludedFile", at = @At("RETURN"), remap = false)
47
    private ImmutableList<String> combatant$compileShaderpackPatch(ImmutableList<String> lines, AbsolutePackPath path) {
48
        if (lines == null || path == null) {
49
            return lines;
50
        }
51
52
        String packName = combatant$currentShaderPackName();
53
        if (combatant$patchSession == null || !Objects.equals(packName, combatant$patchSessionPackName)) {
54
            combatant$patchSessionPackName = packName;
55
            combatant$patchSession = ShaderPatchEngine.newSession(packName);
56
            DebugLog.info("[IrisPatch] IncludeProcessor hook active: shaderPack='%s' active=%s firstPath=%s",
57
                    packName == null ? "" : packName,
58
                    combatant$patchSession.isActive(),
59
                    path.getPathString());
60
        }
61
62
        if (!combatant$patchSession.isActive()) {
63
            return lines;
64
        }
65
66
        IncludeProcessor processor = (IncludeProcessor) (Object) this;
67
        return combatant$patchSession.patch(
68
                path.getPathString(),
69
                lines,
70
                candidate -> processor.getIncludedFile(AbsolutePackPath.fromAbsolutePath(candidate))
71
        );
72
    }
73
}
74
IrisRenderingPipelineFinalizeMixinsrc/main/java/combatant/client/mixins/iris/IrisRenderingPipelineFinalizeMixin.javaJava · 55 lines · 2.0 KB
@Mixin(value = IrisRenderingPipeline.class, remap = false)remap=false
ModifiesIrisRenderingPipeline external mod
IrisRenderingPipelineFinalizeMixin.javaJava · 55 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
11
import net.irisshaders.iris.targets.RenderTargets;
12
import org.spongepowered.asm.mixin.Final;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Pseudo;
15
import org.spongepowered.asm.mixin.Shadow;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.render.engine.depth.PreTranslucentDepth;
20
import combatant.client.render.iris.IrisCombatantFrameHooks;
21
import combatant.client.render.iris.IrisSceneDepth;
22
23
@Pseudo
24
@Mixin(value = IrisRenderingPipeline.class, remap = false)
25
public abstract class IrisRenderingPipelineFinalizeMixin {
26
    @Shadow
27
    @Final
28
    private RenderTargets renderTargets;
29
30
    @Inject(method = "beginLevelRendering", at = @At("HEAD"), remap = false)
31
    private void combatant$resetIrisSceneDepth(CallbackInfo ci) {
32
        IrisSceneDepth.resetFrame();
33
    }
34
35
    @Inject(method = "beginTranslucents", at = @At("HEAD"), remap = false)
36
    private void combatant$capturePreTranslucentDepth(CallbackInfo ci) {
37
        PreTranslucentDepth.capture();
38
    }
39
40
    @Inject(method = "finalizeLevelRendering", at = @At("HEAD"), remap = false)
41
    private void combatant$captureIrisSceneBeforeFinalPass(CallbackInfo ci) {
42
        IrisSceneDepth.capture(renderTargets);
43
    }
44
45
    @Inject(method = "finalizeLevelRendering", at = @At("TAIL"), remap = false)
46
    private void combatant$renderAfterIrisFinalPass(CallbackInfo ci) {
47
        IrisCombatantFrameHooks.renderAfterIrisFinalization();
48
    }
49
50
    @Inject(method = "destroy", at = @At("HEAD"), remap = false)
51
    private void combatant$shutdownDepth(CallbackInfo ci) {
52
        IrisSceneDepth.shutdown();
53
    }
54
}
55
IrisShaderKeyMixinsrc/main/java/combatant/client/mixins/iris/IrisShaderKeyMixin.javaJava · 48 lines · 1.8 KB
@Mixin(value = ShaderKey.class, remap = false)remap=false
ModifiesShaderKey external mod
IrisShaderKeyMixin.javaJava · 48 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.pipeline.RenderPipeline;
13
import net.irisshaders.iris.IrisLogging;
14
import net.irisshaders.iris.pipeline.programs.ShaderKey;
15
import net.irisshaders.iris.shaderpack.loading.ProgramId;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Pseudo;
18
import org.spongepowered.asm.mixin.injection.At;
19
import combatant.client.util.logging.DebugLog;
20
21
@Pseudo
22
@Mixin(value = ShaderKey.class, remap = false)
23
public abstract class IrisShaderKeyMixin {
24
    @WrapOperation(
25
            method = "findBestMatch",
26
            at = @At(
27
                    value = "INVOKE",
28
                    target = "Lnet/irisshaders/iris/IrisLogging;warn(Ljava/lang/String;)V",
29
                    remap = false
30
            ),
31
            remap = false
32
    )
33
    private static void combatant$wrapCombatantProgramMatchWarning(IrisLogging logger,
34
                                                                    String message,
35
                                                                    Operation<Void> original,
36
                                                                    RenderPipeline pipeline,
37
                                                                    ProgramId requestedProgram) {
38
        if (pipeline != null
39
                && pipeline.getLocation() != null
40
                && "combatant".equals(pipeline.getLocation().getNamespace())) {
41
            DebugLog.warn("[Iris] %s", message);
42
            return;
43
        }
44
45
        original.call(logger, message);
46
    }
47
}
48
IrisShaderPackLoadMixinsrc/main/java/combatant/client/mixins/iris/IrisShaderPackLoadMixin.javaJava · 31 lines · 1.2 KB
@Mixin(value = Iris.class, remap = false)remap=false
ModifiesIris external mod
IrisShaderPackLoadMixin.javaJava · 31 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.irisshaders.iris.Iris;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Pseudo;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
16
import combatant.client.render.iris.patch.ShaderPatchEngine;
17
18
@Pseudo
19
@Mixin(value = Iris.class, remap = false)
20
public abstract class IrisShaderPackLoadMixin {
21
    @Inject(method = "loadExternalShaderpack", at = @At("HEAD"), remap = false)
22
    private static void combatant$beginShaderPatchSession(String shaderPackName, CallbackInfoReturnable<Boolean> cir) {
23
        ShaderPatchEngine.beginShaderPackLoad(shaderPackName);
24
    }
25
26
    @Inject(method = "loadExternalShaderpack", at = @At("RETURN"), remap = false)
27
    private static void combatant$endShaderPatchSession(String shaderPackName, CallbackInfoReturnable<Boolean> cir) {
28
        ShaderPatchEngine.endShaderPackLoad(shaderPackName);
29
    }
30
}
31
IrisVanillaHandInteropMixinsrc/main/java/combatant/client/mixins/iris/IrisVanillaHandInteropMixin.javaJava · 62 lines · 2.4 KB
@Mixin(value = GameRenderer.class, priority = 900)priority 900
ModifiesGameRenderer
IrisVanillaHandInteropMixin.javaJava · 62 lines · 2.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.iris;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.renderer.GameRenderer;
12
import net.minecraft.client.renderer.state.level.CameraRenderState;
13
import net.minecraft.world.level.GameType;
14
import org.joml.Matrix4fc;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
import org.spongepowered.asm.mixin.injection.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
import combatant.client.features.module.Modules;
20
import combatant.client.features.module.modules.visuals.Chams;
21
import combatant.client.render.iris.IrisRuntime;
22
23
@Mixin(value = GameRenderer.class, priority = 900)
24
public abstract class IrisVanillaHandInteropMixin {
25
    @Inject(
26
            method = "renderItemInHand(Lnet/minecraft/client/renderer/state/level/CameraRenderState;FLorg/joml/Matrix4fc;)V",
27
            at = @At(
28
                    value = "INVOKE",
29
                    target = "Lorg/joml/Matrix4fStack;popMatrix()Lorg/joml/Matrix4fStack;",
30
                    shift = At.Shift.BEFORE,
31
                    remap = false
32
            )
33
    )
34
    private void combatant$renderHandInFinalScene(CameraRenderState cameraRenderState,
35
                                                  float tickProgress,
36
                                                  Matrix4fc positionMatrix,
37
                                                  CallbackInfo ci) {
38
        if (!IrisRuntime.isShaderpackRendererActive()) {
39
            return;
40
        }
41
42
        Minecraft client = Minecraft.getInstance();
43
        if (client.player == null || client.gameMode == null
44
                || cameraRenderState == null
45
                || cameraRenderState.isPanoramicMode
46
                || cameraRenderState.entityRenderState == null
47
                || cameraRenderState.entityRenderState.isSleeping
48
                || !client.options.getCameraType().isFirstPerson()
49
                || client.gameMode.getPlayerMode() == GameType.SPECTATOR) {
50
            return;
51
        }
52
53
        Chams chams = Modules.get(Chams.class);
54
        if (chams == null || !chams.isActive()) {
55
            return;
56
        }
57
58
        GameRenderer renderer = (GameRenderer) (Object) this;
59
        chams.renderIrisHandMask(renderer, cameraRenderState, positionMatrix, tickProgress);
60
    }
61
}
62
CullingUtilsMixinsrc/main/java/combatant/client/mixins/moreculling/CullingUtilsMixin.javaJava · 46 lines · 1.8 KB
@Mixin(targets = "ca.fxco.moreculling.utils.CullingUtils", remap = false)remap=false
Modifiesca.fxco.moreculling.utils.CullingUtils external mod
CullingUtilsMixin.javaJava · 46 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.moreculling;
9
10
import combatant.client.render.ShaderEspRenderContext;
11
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
12
import net.minecraft.core.BlockPos;
13
import net.minecraft.core.Direction;
14
import net.minecraft.world.phys.Vec3;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Pseudo;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
20
21
@Pseudo
22
@Mixin(targets = "ca.fxco.moreculling.utils.CullingUtils", remap = false)
23
public abstract class CullingUtilsMixin {
24
25
    @Inject(method = "shouldCullBack", at = @At("HEAD"), cancellable = true, remap = false)
26
    private static void combatant$shaderEspKeepsItemFrameBack(ItemFrameRenderState state, CallbackInfoReturnable<Boolean> cir) {
27
        if (ShaderEspRenderContext.isActive()) {
28
            cir.setReturnValue(false);
29
        }
30
    }
31
32
    @Inject(method = "shouldShowMapFace", at = @At("HEAD"), cancellable = true, remap = false)
33
    private static void combatant$shaderEspKeepsMapFace(Direction direction, ItemFrameRenderState state, Vec3 cameraPos, CallbackInfoReturnable<Boolean> cir) {
34
        if (ShaderEspRenderContext.isActive()) {
35
            cir.setReturnValue(true);
36
        }
37
    }
38
39
    @Inject(method = "shouldCullPaintingBack", at = @At("HEAD"), cancellable = true, remap = false)
40
    private static void combatant$shaderEspKeepsPaintingBack(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
41
        if (ShaderEspRenderContext.isActive()) {
42
            cir.setReturnValue(false);
43
        }
44
    }
45
}
46
AbstractSignEditScreenMixinsrc/main/java/combatant/client/mixins/security/AbstractSignEditScreenMixin.javaJava · 51 lines · 1.9 KB
@Mixin(AbstractSignEditScreen.class)
AbstractSignEditScreenMixin.javaJava · 51 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen;
21
import net.minecraft.network.chat.Component;
22
import net.minecraft.world.level.block.entity.SignBlockEntity;
23
import net.minecraft.world.level.block.entity.SignText;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import combatant.client.features.security.BackdoorProtection;
30
31
@Mixin(AbstractSignEditScreen.class)
32
public abstract class AbstractSignEditScreenMixin {
33
34
    @Shadow
35
    private SignText text;
36
37
    @Shadow
38
    private String[] messages;
39
40
    @Inject(
41
            method = "<init>(Lnet/minecraft/world/level/block/entity/SignBlockEntity;ZZLnet/minecraft/network/chat/Component;)V",
42
            at = @At("RETURN")
43
    )
44
    private void combatant$backdoor$filterSignMessages(SignBlockEntity blockEntity, boolean front, boolean filtered, Component title, CallbackInfo ci) {
45
        for (int line = 0; line < this.messages.length; line++) {
46
            Component safeText = BackdoorProtection.filterText(this.text.getMessage(line, filtered));
47
            this.messages[line] = safeText.getString();
48
        }
49
    }
50
}
51
AnvilScreenMixinsrc/main/java/combatant/client/mixins/security/AnvilScreenMixin.javaJava · 42 lines · 1.8 KB
@Mixin(AnvilScreen.class)
ModifiesAnvilScreen
AnvilScreenMixin.javaJava · 42 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
23
import net.minecraft.network.chat.Component;
24
import net.minecraft.world.item.ItemStack;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import combatant.client.features.security.BackdoorProtection;
28
29
@Mixin(AnvilScreen.class)
30
public abstract class AnvilScreenMixin {
31
32
    @WrapOperation(method = "onNameChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getHoverName()Lnet/minecraft/network/chat/Component;"))
33
    private Component combatant$backdoor$filterRenameName(ItemStack stack, Operation<Component> original) {
34
        return BackdoorProtection.filterText(original.call(stack));
35
    }
36
37
    @WrapOperation(method = "slotChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getHoverName()Lnet/minecraft/network/chat/Component;"))
38
    private Component combatant$backdoor$filterSlotUpdateName(ItemStack stack, Operation<Component> original) {
39
        return BackdoorProtection.filterText(original.call(stack));
40
    }
41
}
42
ClientLoginNetworkHandlerMixinsrc/main/java/combatant/client/mixins/security/ClientLoginNetworkHandlerMixin.javaJava · 43 lines · 1.5 KB
@Mixin(ClientHandshakePacketListenerImpl.class)
ClientLoginNetworkHandlerMixin.javaJava · 43 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl;
21
import net.minecraft.network.Connection;
22
import net.minecraft.network.protocol.login.ClientboundLoginFinishedPacket;
23
import org.spongepowered.asm.mixin.Final;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import combatant.client.features.security.BackdoorProtection;
30
31
@Mixin(ClientHandshakePacketListenerImpl.class)
32
public abstract class ClientLoginNetworkHandlerMixin {
33
34
    @Shadow
35
    @Final
36
    private Connection connection;
37
38
    @Inject(method = "handleLoginFinished", at = @At("HEAD"))
39
    private void combatant$backdoor$captureServerConnection(ClientboundLoginFinishedPacket packet, CallbackInfo ci) {
40
        BackdoorProtection.updateServerConnection(connection);
41
    }
42
}
43
GameOptionsMixinsrc/main/java/combatant/client/mixins/security/GameOptionsMixin.javaJava · 48 lines · 1.6 KB
@Mixin(Options.class)
ModifiesOptions
GameOptionsMixin.javaJava · 48 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import net.minecraft.client.KeyMapping;
21
import net.minecraft.client.Minecraft;
22
import net.minecraft.client.Options;
23
import org.spongepowered.asm.mixin.Final;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.Shadow;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.Inject;
28
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
29
import combatant.client.features.security.BackdoorProtection;
30
31
import java.io.File;
32
33
@Mixin(Options.class)
34
public abstract class GameOptionsMixin {
35
36
    @Shadow
37
    @Final
38
    public KeyMapping[] keyMappings;
39
40
    @Inject(method = "<init>(Lnet/minecraft/client/Minecraft;Ljava/io/File;)V", at = @At("TAIL"))
41
    private void combatant$backdoor$registerVanillaKeybinds(Minecraft client, File optionsFile, CallbackInfo ci) {
42
        BackdoorProtection.resetVanillaKeybinds();
43
        for (KeyMapping keyBinding : keyMappings) {
44
            BackdoorProtection.registerVanillaKeybind(keyBinding.getName());
45
        }
46
    }
47
}
48
NetworkUtilsMixinsrc/main/java/combatant/client/mixins/security/NetworkUtilsMixin.javaJava · 96 lines · 3.7 KB
@Mixin(HttpUtil.class)
ModifiesHttpUtil
NetworkUtilsMixin.javaJava · 96 lines · 3.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22
import com.llamalad7.mixinextras.sugar.Local;
23
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
24
import net.minecraft.util.HttpUtil;
25
import org.spongepowered.asm.mixin.Mixin;
26
import org.spongepowered.asm.mixin.injection.At;
27
import org.spongepowered.asm.mixin.injection.ModifyVariable;
28
import combatant.client.features.security.BackdoorProtection;
29
30
import java.io.IOException;
31
import java.io.InputStream;
32
import java.net.HttpURLConnection;
33
import java.net.ProtocolException;
34
import java.net.Proxy;
35
import java.net.URL;
36
import java.nio.file.Path;
37
import java.util.Map;
38
39
@Mixin(HttpUtil.class)
40
public abstract class NetworkUtilsMixin {
41
42
    @ModifyVariable(method = "downloadFile", at = @At("HEAD"), argsOnly = true, ordinal = 0)
43
    private static Path combatant$backdoor$isolatePackCache(Path original) {
44
        return BackdoorProtection.isolatePackCachePath(original);
45
    }
46
47
    @WrapOperation(method = "downloadFile", at = @At(value = "INVOKE", target = "Ljava/net/HttpURLConnection;getInputStream()Ljava/io/InputStream;"))
48
    private static InputStream combatant$backdoor$guardLocalRedirects(
49
            HttpURLConnection connection,
50
            Operation<InputStream> original,
51
            @Local(argsOnly = true) Map<String, String> headers,
52
            @Local(argsOnly = true) Proxy proxy,
53
            @Local LocalRef<HttpURLConnection> httpURLConnection
54
    ) throws IOException {
55
        HttpURLConnection current = connection;
56
        BackdoorProtection.assertRemoteUrlAllowed(current.getURL());
57
        current.setInstanceFollowRedirects(false);
58
59
        int redirects = 0;
60
        int status = current.getResponseCode();
61
        while (isRedirect(status, current.getHeaderField("Location"))) {
62
            if (++redirects > 20) {
63
                throw new ProtocolException("Too many redirects while downloading resource pack");
64
            }
65
66
            URL next = resolveRedirect(current);
67
            BackdoorProtection.assertRemoteUrlAllowed(next);
68
69
            current = (HttpURLConnection) next.openConnection(proxy);
70
            current.setInstanceFollowRedirects(false);
71
            headers.forEach(current::setRequestProperty);
72
            status = current.getResponseCode();
73
        }
74
75
        httpURLConnection.set(current);
76
        return original.call(current);
77
    }
78
79
    private static boolean isRedirect(int status, String location) {
80
        if (location == null || location.isBlank()) return false;
81
        return status == 301 || status == 302 || status == 303 || status == 307 || status == 308;
82
    }
83
84
    private static URL resolveRedirect(HttpURLConnection connection) throws IOException {
85
        String location = connection.getHeaderField("Location");
86
        if (location == null || location.isBlank()) {
87
            throw new ProtocolException("Redirect response without Location header");
88
        }
89
        try {
90
            return new URL(location);
91
        } catch (Exception ignored) {
92
            return new URL(connection.getURL(), location);
93
        }
94
    }
95
}
96
TranslatableTextContentMixinsrc/main/java/combatant/client/mixins/security/TranslatableTextContentMixin.javaJava · 47 lines · 2.1 KB
@Mixin(TranslatableContents.class)
TranslatableTextContentMixin.javaJava · 47 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22
import net.minecraft.locale.Language;
23
import net.minecraft.network.chat.contents.TranslatableContents;
24
import org.spongepowered.asm.mixin.Mixin;
25
import org.spongepowered.asm.mixin.injection.At;
26
import combatant.client.features.security.FilteredTranslatableTextContent;
27
28
@Mixin(TranslatableContents.class)
29
public abstract class TranslatableTextContentMixin {
30
31
    @WrapOperation(method = "decompose", at = @At(value = "INVOKE", target = "Lnet/minecraft/locale/Language;getOrDefault(Ljava/lang/String;)Ljava/lang/String;"))
32
    private String combatant$backdoor$resolveNoFallback(Language language, String key, Operation<String> original) {
33
        if ((Object) this instanceof FilteredTranslatableTextContent filtered && filtered.getResolved() != null) {
34
            return filtered.getResolved();
35
        }
36
        return original.call(language, key);
37
    }
38
39
    @WrapOperation(method = "decompose", at = @At(value = "INVOKE", target = "Lnet/minecraft/locale/Language;getOrDefault(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"))
40
    private String combatant$backdoor$resolveFallback(Language language, String key, String fallback, Operation<String> original) {
41
        if ((Object) this instanceof FilteredTranslatableTextContent filtered && filtered.getResolved() != null) {
42
            return filtered.getResolved();
43
        }
44
        return original.call(language, key, fallback);
45
    }
46
}
47
TranslationStorageMixinsrc/main/java/combatant/client/mixins/security/TranslationStorageMixin.javaJava · 61 lines · 2.5 KB
@Mixin(ClientLanguage.class)
TranslationStorageMixin.javaJava · 61 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Combatant modifications copyright (c) 2026 pivosos2007.
4
 *
5
 * Portions of this file are based on ExploitPreventer.
6
 * Original work copyright (c) 2025 Niklas S.
7
 *
8
 * Original portions remain under the MIT License.
9
 * Combatant modifications are licensed under GPLv3.
10
 * See THIRD_PARTY_NOTICES.md for details.
11
 */
12
13
/*
14
 * Portions of this file adapt protection logic from ExploitPreventer.
15
 * Original work copyright (c) 2025 Niklas S.
16
 * Licensed under MIT; see THIRD_PARTY_NOTICES.md.
17
 */
18
package combatant.client.mixins.security;
19
20
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22
import com.llamalad7.mixinextras.sugar.Local;
23
import net.minecraft.client.resources.language.ClientLanguage;
24
import net.minecraft.server.packs.resources.Resource;
25
import net.minecraft.server.packs.resources.ResourceManager;
26
import org.spongepowered.asm.mixin.Mixin;
27
import org.spongepowered.asm.mixin.injection.At;
28
import org.spongepowered.asm.mixin.injection.Inject;
29
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30
import combatant.client.features.security.BackdoorProtection;
31
32
import java.io.InputStream;
33
import java.util.List;
34
import java.util.function.BiConsumer;
35
36
@Mixin(ClientLanguage.class)
37
public abstract class TranslationStorageMixin {
38
39
    @Inject(method = "loadFrom(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/List;Z)Lnet/minecraft/client/resources/language/ClientLanguage;", at = @At("HEAD"))
40
    private static void combatant$backdoor$resetLoadedTranslations(ResourceManager resourceManager, List<String> definitions, boolean rightToLeft, CallbackInfoReturnable<ClientLanguage> cir) {
41
        BackdoorProtection.resetLoadedTranslations();
42
    }
43
44
    @WrapOperation(
45
            method = "appendFrom(Ljava/lang/String;Ljava/util/List;Ljava/util/Map;)V",
46
            at = @At(value = "INVOKE", target = "Lnet/minecraft/locale/Language;loadFromJson(Ljava/io/InputStream;Ljava/util/function/BiConsumer;)V")
47
    )
48
    private static void combatant$backdoor$captureTranslations(
49
            InputStream inputStream,
50
            BiConsumer<String, String> consumer,
51
            Operation<Void> original,
52
            @Local Resource resource
53
    ) {
54
        String packId = resource.sourcePackId();
55
        original.call(inputStream, (BiConsumer<String, String>) (key, value) -> {
56
            BackdoorProtection.registerTranslationKey(key, packId);
57
            consumer.accept(key, value);
58
        });
59
    }
60
}
61
SodiumBlockRendererMixinsrc/main/java/combatant/client/mixins/sodium/SodiumBlockRendererMixin.javaJava · 118 lines · 5.8 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer")
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer external mod
SodiumBlockRendererMixin.javaJava · 118 lines · 5.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import combatant.client.render.engine.material.MaterialClassification;
12
import combatant.client.render.engine.material.MaterialDomain;
13
import combatant.client.render.engine.material.MaterialRegistry;
14
import combatant.client.render.engine.material.MaterialSurfaceDescriptor;
15
import combatant.client.render.helpers.SodiumSurfaceFlagContext;
16
import combatant.client.render.sodium.terrain.CombatantChunkVertexExtension;
17
import combatant.client.render.sodium.fluid.WaterSurfaceExtractor;
18
import combatant.client.render.sodium.fluid.HeightSurfacePatchRouting;
19
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses;
20
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material;
21
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder;
22
import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl;
23
import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache;
24
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
25
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
26
import net.minecraft.core.BlockPos;
27
import net.minecraft.world.level.block.state.BlockState;
28
import org.objectweb.asm.Opcodes;
29
import org.spongepowered.asm.mixin.Mixin;
30
import org.spongepowered.asm.mixin.Pseudo;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.Final;
33
import org.spongepowered.asm.mixin.injection.At;
34
import org.spongepowered.asm.mixin.injection.Inject;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
36
37
@Pseudo
38
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer")
39
public abstract class SodiumBlockRendererMixin {
40
    @Shadow(remap = false) @Final private ChunkVertexEncoder.Vertex[] vertices;
41
42
43
    @Inject(method = "renderModel", at = @At("HEAD"), remap = false)
44
    private void combatant$pushSurfaceState(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
45
        SodiumSurfaceFlagContext.pushForState(state, pos, origin);
46
    }
47
48
    @Inject(method = "renderModel", at = @At("RETURN"), remap = false)
49
    private void combatant$popSurfaceState(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
50
        SodiumSurfaceFlagContext.pop();
51
    }
52
53
    @Inject(
54
            method = "bufferQuad",
55
            at = @At(
56
                    value = "FIELD",
57
                    target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexEncoder$Vertex;light:I",
58
                    opcode = Opcodes.PUTFIELD,
59
                    shift = At.Shift.AFTER),
60
            remap = false
61
    )
62
    private void combatant$writeSurfaceContract(MutableQuadViewImpl quad,
63
                                                 float[] brightness,
64
                                                 Material material,
65
                                                 CallbackInfo ci,
66
                                                 @Local(ordinal = 0) ChunkVertexEncoder.Vertex vertex) {
67
        CombatantChunkVertexExtension extension = (CombatantChunkVertexExtension) vertex;
68
        extension.combatant$setSurfaceFlags(SodiumSurfaceFlagContext.getSurfaceFlags(vertex.y));
69
70
        TextureAtlasSprite sprite = quad.sprite(SpriteFinderCache.forBlockAtlas());
71
        MaterialClassification classification = SodiumSurfaceFlagContext.materialClassification(combatant$domain(material));
72
        MaterialSurfaceDescriptor descriptor = MaterialRegistry.global().resolve(sprite, classification);
73
        extension.combatant$setMaterialData(
74
                descriptor.stableId(),
75
                MaterialRegistry.global().gpuPresenceMask(descriptor),
76
                descriptor.gpuFeatureMask16(),
77
                descriptor.packScalarSurface()
78
        );
79
    }
80
81
    @Inject(
82
            method = "bufferQuad",
83
            at = @At(
84
                    value = "INVOKE",
85
                    target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;isTranslucent()Z",
86
                    shift = At.Shift.BEFORE
87
            ),
88
            remap = false,
89
            cancellable = true
90
    )
91
    private void combatant$extractExplicitHeightPatch(MutableQuadViewImpl quad,
92
                                                       float[] brightness,
93
                                                       Material material,
94
                                                       CallbackInfo ci) {
95
        TextureAtlasSprite sprite = quad.sprite(SpriteFinderCache.forBlockAtlas());
96
        MaterialClassification classification = SodiumSurfaceFlagContext.materialClassification(combatant$domain(material));
97
        MaterialSurfaceDescriptor descriptor = MaterialRegistry.global().resolve(sprite, classification);
98
        boolean captured = WaterSurfaceExtractor.captureHeight(
99
                SodiumSurfaceFlagContext.worldPos(),
100
                SodiumSurfaceFlagContext.renderOrigin(),
101
                quad,
102
                descriptor,
103
                vertices
104
        );
105
        if (captured && HeightSurfacePatchRouting.replacementActive()) {
106
            ci.cancel();
107
        }
108
    }
109
110
    private static MaterialDomain combatant$domain(Material material) {
111
        if (material == null || material.pass == null) return MaterialDomain.UNKNOWN;
112
        if (material.pass == DefaultTerrainRenderPasses.SOLID) return MaterialDomain.OPAQUE;
113
        if (material.pass == DefaultTerrainRenderPasses.CUTOUT) return MaterialDomain.CUTOUT;
114
        if (material.pass == DefaultTerrainRenderPasses.TRANSLUCENT) return MaterialDomain.TRANSLUCENT;
115
        return MaterialDomain.UNKNOWN;
116
    }
117
}
118
SodiumBlockVisibilityMixinsrc/main/java/combatant/client/mixins/sodium/SodiumBlockVisibilityMixin.javaJava · 65 lines · 2.6 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer")
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer external mod
SodiumBlockVisibilityMixin.javaJava · 65 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material;
11
import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl;
12
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
13
import net.minecraft.core.BlockPos;
14
import net.minecraft.world.level.block.state.BlockState;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Pseudo;
17
import org.spongepowered.asm.mixin.Unique;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21
import combatant.client.util.block.BlockObservationHub;
22
23
import java.util.ArrayDeque;
24
25
@Pseudo
26
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer")
27
public abstract class SodiumBlockVisibilityMixin {
28
    @Unique
29
    private static final ThreadLocal<ArrayDeque<RenderedBlock>> COMBATANT_BLOCK_STACK =
30
            ThreadLocal.withInitial(ArrayDeque::new);
31
32
    @Inject(method = "renderModel", at = @At("HEAD"), remap = false)
33
    private void combatant$pushRenderedBlock(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
34
        COMBATANT_BLOCK_STACK.get().addLast(new RenderedBlock(pos, state));
35
    }
36
37
    @Inject(method = "renderModel", at = @At("RETURN"), remap = false)
38
    private void combatant$popRenderedBlock(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
39
        ArrayDeque<RenderedBlock> stack = COMBATANT_BLOCK_STACK.get();
40
        if (!stack.isEmpty()) {
41
            stack.removeLast();
42
        }
43
        if (stack.isEmpty()) {
44
            COMBATANT_BLOCK_STACK.remove();
45
        }
46
    }
47
48
    @Inject(method = "bufferQuad", at = @At("HEAD"), remap = false)
49
    private void combatant$observeBufferedQuad(MutableQuadViewImpl quad,
50
                                               float[] brightness,
51
                                               Material material,
52
                                               CallbackInfo ci) {
53
        ArrayDeque<RenderedBlock> stack = COMBATANT_BLOCK_STACK.get();
54
        if (stack.isEmpty()) {
55
            return;
56
        }
57
58
        RenderedBlock rendered = stack.peekLast();
59
        BlockObservationHub.observeSodiumRenderedBlock(rendered.pos(), rendered.state());
60
    }
61
62
    private record RenderedBlock(BlockPos pos, BlockState state) {
63
    }
64
}
65
SodiumChunkBuilderMeshingTaskMixinsrc/main/java/combatant/client/mixins/sodium/SodiumChunkBuilderMeshingTaskMixin.javaJava · 66 lines · 3.4 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask")
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask external mod
SodiumChunkBuilderMeshingTaskMixin.javaJava · 66 lines · 3.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import net.minecraft.world.level.block.state.BlockState;
12
import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext;
13
import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput;
14
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderTask;
15
import net.caffeinemc.mods.sodium.client.util.task.CancellationToken;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Pseudo;
18
import org.spongepowered.asm.mixin.injection.At;
19
import org.spongepowered.asm.mixin.injection.ModifyVariable;
20
import org.spongepowered.asm.mixin.injection.Inject;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
22
import combatant.client.util.block.BlockObservationHub;
23
import combatant.client.render.sodium.fluid.WaterSurfaceExtractor;
24
25
@Pseudo
26
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask")
27
public abstract class SodiumChunkBuilderMeshingTaskMixin {
28
29
    @Inject(
30
            method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
31
            at = @At("HEAD"),
32
            remap = false
33
    )
34
    private void combatant$beginSurfaceExtraction(ChunkBuildContext context,
35
                                                   CancellationToken cancellationToken,
36
                                                   CallbackInfoReturnable<ChunkBuildOutput> cir) {
37
        ChunkBuilderTask<?> task = (ChunkBuilderTask<?>)(Object)this;
38
        WaterSurfaceExtractor.beginSection(task.getRenderSection().getPosition().asLong());
39
    }
40
41
    @Inject(
42
            method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
43
            at = @At("RETURN"),
44
            remap = false
45
    )
46
    private void combatant$finishSurfaceExtraction(ChunkBuildContext context,
47
                                                    CancellationToken cancellationToken,
48
                                                    CallbackInfoReturnable<ChunkBuildOutput> cir) {
49
        WaterSurfaceExtractor.finishSection(cir.getReturnValue() != null);
50
    }
51
52
    @ModifyVariable(
53
            method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
54
            at = @At("STORE"),
55
            ordinal = 0,
56
            remap = false
57
    )
58
    private BlockState combatant$captureSodiumSectionBlock(BlockState state,
59
                                                           @Local(index = 22) int x,
60
                                                           @Local(index = 20) int y,
61
                                                           @Local(index = 21) int z) {
62
        BlockObservationHub.observeSodiumBlock(x, y, z, state);
63
        return state;
64
    }
65
}
66
SodiumChunkMeshFormatsMixinsrc/main/java/combatant/client/mixins/sodium/SodiumChunkMeshFormatsMixin.javaJava · 30 lines · 1.2 KB
@Mixin(ChunkMeshFormats.class)
ModifiesChunkMeshFormats external mod
SodiumChunkMeshFormatsMixin.javaJava · 30 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import combatant.client.render.sodium.terrain.CombatantChunkMeshFormats;
11
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkMeshFormats;
12
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
17
18
/**
19
 * Sodium 0.9.1 routes the vertex format used by the renderer, builder and
20
 * region arenas through this method. Replacing it here keeps all three users
21
 * on Combatant's extended terrain layout.
22
 */
23
@Mixin(ChunkMeshFormats.class)
24
public abstract class SodiumChunkMeshFormatsMixin {
25
    @Inject(method = "getCurrent", at = @At("HEAD"), cancellable = true, remap = false)
26
    private static void combatant$useExtendedVertexFormat(CallbackInfoReturnable<ChunkVertexType> cir) {
27
        cir.setReturnValue(CombatantChunkMeshFormats.SURFACE_FLAGS);
28
    }
29
}
30
SodiumChunkVertexMixinsrc/main/java/combatant/client/mixins/sodium/SodiumChunkVertexMixin.javaJava · 85 lines · 2.8 KB
@Mixin(ChunkVertexEncoder.Vertex.class)
ModifiesChunkVertexEncoder.Vertex external mod
SodiumChunkVertexMixin.javaJava · 85 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Unique;
13
import org.spongepowered.asm.mixin.injection.At;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16
import combatant.client.render.sodium.terrain.CombatantChunkVertexExtension;
17
18
@Mixin(ChunkVertexEncoder.Vertex.class)
19
public abstract class SodiumChunkVertexMixin implements CombatantChunkVertexExtension {
20
    @Unique
21
    private int combatant$surfaceFlags;
22
    @Unique
23
    private int combatant$materialId;
24
    @Unique
25
    private int combatant$materialMapPresenceMask;
26
    @Unique
27
    private int combatant$materialFeatureMask;
28
    @Unique
29
    private int combatant$packedScalarSurface;
30
31
    @Inject(method = "copyVertexTo", at = @At("HEAD"))
32
    private static void combatant$copyVertexData(ChunkVertexEncoder.Vertex from, ChunkVertexEncoder.Vertex to, CallbackInfo ci) {
33
        ((CombatantChunkVertexExtension) from).combatant$copyData((CombatantChunkVertexExtension) to);
34
    }
35
36
    @Override
37
    public void combatant$setSurfaceFlags(int surfaceFlags) {
38
        this.combatant$surfaceFlags = surfaceFlags;
39
    }
40
41
    @Override
42
    public int combatant$getSurfaceFlags() {
43
        return this.combatant$surfaceFlags;
44
    }
45
46
    @Override
47
    public void combatant$setMaterialData(int materialId, int mapPresenceMask, int featureMask, int packedScalarSurface) {
48
        this.combatant$materialId = materialId;
49
        this.combatant$materialMapPresenceMask = mapPresenceMask & 0xFF;
50
        this.combatant$materialFeatureMask = featureMask & 0xFFFF;
51
        this.combatant$packedScalarSurface = packedScalarSurface;
52
    }
53
54
    @Override
55
    public int combatant$getMaterialId() {
56
        return this.combatant$materialId;
57
    }
58
59
    @Override
60
    public int combatant$getMaterialMapPresenceMask() {
61
        return this.combatant$materialMapPresenceMask;
62
    }
63
64
    @Override
65
    public int combatant$getMaterialFeatureMask() {
66
        return this.combatant$materialFeatureMask;
67
    }
68
69
    @Override
70
    public int combatant$getPackedScalarSurface() {
71
        return this.combatant$packedScalarSurface;
72
    }
73
74
    @Override
75
    public void combatant$copyData(CombatantChunkVertexExtension dest) {
76
        dest.combatant$setSurfaceFlags(this.combatant$surfaceFlags);
77
        dest.combatant$setMaterialData(
78
                this.combatant$materialId,
79
                this.combatant$materialMapPresenceMask,
80
                this.combatant$materialFeatureMask,
81
                this.combatant$packedScalarSurface
82
        );
83
    }
84
}
85
SodiumDefaultChunkRendererMixinsrc/main/java/combatant/client/mixins/sodium/SodiumDefaultChunkRendererMixin.javaJava · 160 lines · 7.4 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.DefaultChunkRenderer", remap = false)remap=false
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.DefaultChunkRenderer external mod
SodiumDefaultChunkRendererMixin.javaJava · 160 lines · 7.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
11
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
12
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
13
import com.llamalad7.mixinextras.sugar.Local;
14
import com.mojang.blaze3d.systems.CommandEncoder;
15
import com.mojang.blaze3d.systems.RenderPass;
16
import com.mojang.blaze3d.systems.RenderSystem;
17
import com.mojang.blaze3d.textures.GpuTextureView;
18
import com.mojang.blaze3d.textures.GpuSampler;
19
import combatant.client.render.engine.core.CombatantRenderSystem;
20
import combatant.client.render.engine.material.MaterialAtlasManager;
21
import combatant.client.render.sodium.SodiumSecondaryTerrainContext;
22
import combatant.client.util.logging.DebugLog;
23
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
24
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
25
import net.minecraft.client.Minecraft;
26
import org.joml.Vector4fc;
27
import org.lwjgl.opengl.GL11C;
28
import org.lwjgl.system.MemoryStack;
29
import org.objectweb.asm.Opcodes;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Pseudo;
32
import org.spongepowered.asm.mixin.injection.At;
33
34
import java.util.Optional;
35
import java.util.OptionalDouble;
36
import java.nio.IntBuffer;
37
import java.util.function.Supplier;
38
39
/** Connects Sodium's already-batched terrain phase to Combatant's geometry attachments. */
40
@Pseudo
41
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.DefaultChunkRenderer", remap = false)
42
public abstract class SodiumDefaultChunkRendererMixin {
43
    @WrapOperation(
44
            method = "render",
45
            at = @At(
46
                    value = "INVOKE",
47
                    target = "Lcom/mojang/blaze3d/systems/CommandEncoder;createRenderPass(Ljava/util/function/Supplier;Lcom/mojang/blaze3d/textures/GpuTextureView;Ljava/util/Optional;Lcom/mojang/blaze3d/textures/GpuTextureView;Ljava/util/OptionalDouble;)Lcom/mojang/blaze3d/systems/RenderPass;"
48
            )
49
    )
50
    private RenderPass combatant$openDeferredTerrainPass(
51
            CommandEncoder encoder,
52
            Supplier<String> label,
53
            GpuTextureView color,
54
            Optional<Vector4fc> clearColor,
55
            GpuTextureView depth,
56
            OptionalDouble clearDepth,
57
            Operation<RenderPass> original,
58
            @Local(argsOnly = true) ChunkRenderMatrices matrices,
59
            @Local(argsOnly = true) TerrainRenderPass terrainPass
60
    ) {
61
        SodiumSecondaryTerrainContext.State secondary = SodiumSecondaryTerrainContext.current();
62
        if (secondary != null) {
63
            return secondary.openPass(encoder, label);
64
        }
65
        if (terrainPass.isTranslucent() || !CombatantRenderSystem.deferredWorld().enabled()) {
66
            return original.call(encoder, label, color, clearColor, depth, clearDepth);
67
        }
68
        RenderPass pass = CombatantRenderSystem.deferredWorld().openGeometryPass(
69
                encoder, label, color, clearColor, depth, clearDepth
70
        );
71
        combatant$logPrimaryCaptureContract(matrices, color, depth);
72
        return pass;
73
    }
74
75
    /**
76
     * One-shot producer-side contract dump. This runs after Blaze3D opened the actual MRT pass, so
77
     * the queried OpenGL viewport is the viewport used by the following Sodium terrain draws, not
78
     * stale state left by a secondary atlas pass.
79
     */
80
    private static void combatant$logPrimaryCaptureContract(ChunkRenderMatrices matrices,
81
                                                            GpuTextureView color,
82
                                                            GpuTextureView depth) {
83
        if (matrices == null || color == null) return;
84
        int viewportX = -1;
85
        int viewportY = -1;
86
        int viewportWidth = -1;
87
        int viewportHeight = -1;
88
        String backend = RenderSystem.getDevice().getDeviceInfo().backendName();
89
        if (backend != null && backend.toLowerCase(java.util.Locale.ROOT).contains("opengl")) {
90
            try (MemoryStack stack = MemoryStack.stackPush()) {
91
                IntBuffer viewport = stack.mallocInt(4);
92
                GL11C.glGetIntegerv(GL11C.GL_VIEWPORT, viewport);
93
                viewportX = viewport.get(0);
94
                viewportY = viewport.get(1);
95
                viewportWidth = viewport.get(2);
96
                viewportHeight = viewport.get(3);
97
            }
98
        }
99
100
        Minecraft minecraft = Minecraft.getInstance();
101
        int windowWidth = minecraft != null && minecraft.getWindow() != null
102
                ? minecraft.getWindow().getWidth() : -1;
103
        int windowHeight = minecraft != null && minecraft.getWindow() != null
104
                ? minecraft.getWindow().getHeight() : -1;
105
        int depthWidth = depth != null ? depth.getWidth(0) : -1;
106
        int depthHeight = depth != null ? depth.getHeight(0) : -1;
107
        org.joml.Matrix4fc p = matrices.projection();
108
        org.joml.Matrix4fc v = matrices.modelView();
109
        DebugLog.infoOnce(
110
                "combatant.deferred.primary-capture-contract",
111
                "[Deferred][PrimaryCapture] target=%dx%d depth=%dx%d viewport=%d,%d %dx%d window=%dx%d "
112
                        + "projection=[%f,%f,%f,%f;%f,%f,%f,%f;%f,%f,%f,%f;%f,%f,%f,%f] "
113
                        + "modelView=[%f,%f,%f,%f;%f,%f,%f,%f;%f,%f,%f,%f;%f,%f,%f,%f]",
114
                color.getWidth(0), color.getHeight(0), depthWidth, depthHeight,
115
                viewportX, viewportY, viewportWidth, viewportHeight, windowWidth, windowHeight,
116
                p.m00(), p.m01(), p.m02(), p.m03(),
117
                p.m10(), p.m11(), p.m12(), p.m13(),
118
                p.m20(), p.m21(), p.m22(), p.m23(),
119
                p.m30(), p.m31(), p.m32(), p.m33(),
120
                v.m00(), v.m01(), v.m02(), v.m03(),
121
                v.m10(), v.m11(), v.m12(), v.m13(),
122
                v.m20(), v.m21(), v.m22(), v.m23(),
123
                v.m30(), v.m31(), v.m32(), v.m33()
124
        );
125
    }
126
    @WrapOperation(
127
            method = "render",
128
            at = @At(
129
                    value = "INVOKE",
130
                    target = "Lcom/mojang/blaze3d/systems/RenderPass;bindTexture(Ljava/lang/String;Lcom/mojang/blaze3d/textures/GpuTextureView;Lcom/mojang/blaze3d/textures/GpuSampler;)V"
131
            )
132
    )
133
    private void combatant$bindMaterialAtlases(
134
            RenderPass pass,
135
            String name,
136
            GpuTextureView view,
137
            GpuSampler sampler,
138
            Operation<Void> original,
139
            @Local(argsOnly = true) TerrainRenderPass terrainPass
140
    ) {
141
        original.call(pass, name, view, sampler);
142
        if (!"u_BlockTex".equals(name)) return;
143
        if (terrainPass.isTranslucent() || SodiumSecondaryTerrainContext.active()) return;
144
        if (!CombatantRenderSystem.deferredWorld().enabled()) return;
145
        MaterialAtlasManager.global().bind(pass, sampler, view);
146
    }
147
148
    @ModifyExpressionValue(
149
            method = "render",
150
            at = @At(
151
                    value = "FIELD",
152
                    target = "Lnet/caffeinemc/mods/sodium/client/gui/SodiumOptions$PerformanceSettings;useBlockFaceCulling:Z",
153
                    opcode = Opcodes.GETFIELD)
154
    )
155
    private boolean combatant$disablePrimaryCameraFaceCullingForSecondaryView(boolean original) {
156
        return SodiumSecondaryTerrainContext.active() ? false : original;
157
    }
158
159
}
160
SodiumDefaultFluidRendererMixinsrc/main/java/combatant/client/mixins/sodium/SodiumDefaultFluidRendererMixin.javaJava · 119 lines · 6.2 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.DefaultFluidRenderer")
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.DefaultFluidRenderer external mod
SodiumDefaultFluidRendererMixin.javaJava · 119 lines · 6.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 * Licensed under the GNU General Public License v3.0.
5
 */
6
package combatant.client.mixins.sodium;
7
8
import combatant.client.render.engine.material.MaterialClassification;
9
import combatant.client.render.engine.material.MaterialRegistry;
10
import combatant.client.render.engine.material.MaterialSurfaceDescriptor;
11
import combatant.client.render.sodium.fluid.FluidSurfaceContext;
12
import combatant.client.render.sodium.fluid.FluidSurfaceData;
13
import combatant.client.render.sodium.fluid.WaterSurfaceExtractor;
14
import combatant.client.render.sodium.fluid.WaterSurfacePatchRouting;
15
import combatant.client.render.sodium.terrain.CombatantChunkVertexExtension;
16
import net.caffeinemc.mods.sodium.client.model.color.ColorProvider;
17
import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView;
18
import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing;
19
import net.caffeinemc.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder;
20
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material;
21
import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector;
22
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder;
23
import net.caffeinemc.mods.sodium.client.world.LevelSlice;
24
import net.minecraft.client.renderer.block.FluidModel;
25
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
26
import net.minecraft.core.BlockPos;
27
import net.minecraft.world.level.block.state.BlockState;
28
import net.minecraft.world.level.material.FluidState;
29
import org.spongepowered.asm.mixin.Final;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Pseudo;
32
import org.spongepowered.asm.mixin.Shadow;
33
import org.spongepowered.asm.mixin.injection.At;
34
import org.spongepowered.asm.mixin.injection.Inject;
35
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
36
37
/** Adds Combatant's exact fluid/material contract to Sodium's default quad producer. */
38
@Pseudo
39
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.DefaultFluidRenderer")
40
public abstract class SodiumDefaultFluidRendererMixin {
41
    @Shadow(remap = false)
42
    @Final
43
    private ChunkVertexEncoder.Vertex[] vertices;
44
45
    @Inject(method = "render", at = @At("HEAD"), remap = false)
46
    private void combatant$pushFluidSurface(LevelSlice level,
47
                                            BlockState blockState,
48
                                            FluidState fluidState,
49
                                            BlockPos worldPos,
50
                                            BlockPos renderOrigin,
51
                                            TranslucentGeometryCollector collector,
52
                                            ChunkModelBuilder builder,
53
                                            Material material,
54
                                            ColorProvider<FluidState> colorProvider,
55
                                            FluidModel model,
56
                                            CallbackInfo ci) {
57
        FluidSurfaceContext.push(level, blockState, fluidState, worldPos, renderOrigin);
58
    }
59
60
    @Inject(method = "render", at = @At("RETURN"), remap = false)
61
    private void combatant$popFluidSurface(LevelSlice level,
62
                                           BlockState blockState,
63
                                           FluidState fluidState,
64
                                           BlockPos worldPos,
65
                                           BlockPos renderOrigin,
66
                                           TranslucentGeometryCollector collector,
67
                                           ChunkModelBuilder builder,
68
                                           Material material,
69
                                           ColorProvider<FluidState> colorProvider,
70
                                           FluidModel model,
71
                                           CallbackInfo ci) {
72
        FluidSurfaceContext.pop();
73
    }
74
75
    @Inject(
76
            method = "writeQuad",
77
            at = @At(
78
                    value = "INVOKE",
79
                    target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/material/Material;isTranslucent()Z",
80
                    shift = At.Shift.BEFORE
81
            ),
82
            remap = false,
83
            cancellable = true
84
    )
85
    private void combatant$stampFluidMaterial(ChunkModelBuilder builder,
86
                                              TranslucentGeometryCollector collector,
87
                                              Material sodiumMaterial,
88
                                              BlockPos renderOrigin,
89
                                              ModelQuadView quad,
90
                                              ModelQuadFacing facing,
91
                                              boolean reversed,
92
                                              CallbackInfo ci) {
93
        FluidSurfaceContext.Entry context = FluidSurfaceContext.current();
94
        if (context == null || quad == null) return;
95
96
        TextureAtlasSprite sprite = quad.getSprite();
97
        MaterialClassification classification = context.classification();
98
        MaterialSurfaceDescriptor descriptor = MaterialRegistry.global().resolve(sprite, classification);
99
        int mapMask = MaterialRegistry.global().gpuPresenceMask(descriptor);
100
        int featureMask = descriptor.gpuFeatureMask16();
101
        int packedSurface = descriptor.packScalarSurface();
102
        for (ChunkVertexEncoder.Vertex vertex : vertices) {
103
            CombatantChunkVertexExtension extension = (CombatantChunkVertexExtension) vertex;
104
            extension.combatant$setSurfaceFlags(0);
105
            extension.combatant$setMaterialData(descriptor.stableId(), mapMask, featureMask, packedSurface);
106
        }
107
108
        FluidSurfaceData surface = FluidSurfaceData.fromCurrent(
109
                quad, facing, reversed, descriptor, vertices, mapMask, featureMask, packedSurface
110
        );
111
        WaterSurfaceExtractor.capture(surface);
112
        if (surface != null && surface.isTopSurface()
113
                && surface.domain() == combatant.client.render.engine.material.MaterialDomain.WATER
114
                && WaterSurfacePatchRouting.replacementActive()) {
115
            ci.cancel();
116
        }
117
    }
118
}
119
SodiumQueuedSectionStorageMixinsrc/main/java/combatant/client/mixins/sodium/SodiumQueuedSectionStorageMixin.javaJava · 88 lines · 3.2 KB
@Mixin(value = QueuedSectionStorage.class, remap = false)remap=false
ModifiesQueuedSectionStorage external mod
SodiumQueuedSectionStorageMixin.javaJava · 88 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import combatant.client.render.sodium.SodiumSectionStorageView;
11
import it.unimi.dsi.fastutil.longs.Long2ReferenceMap;
12
import it.unimi.dsi.fastutil.longs.LongSet;
13
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection;
14
import net.caffeinemc.mods.sodium.client.render.chunk.storage.QueuedSectionStorage;
15
import org.spongepowered.asm.mixin.Final;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.Pseudo;
18
import org.spongepowered.asm.mixin.Shadow;
19
import org.spongepowered.asm.mixin.Unique;
20
import org.spongepowered.asm.mixin.injection.At;
21
import org.spongepowered.asm.mixin.injection.Inject;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
24
25
/** Sodium 0.9.1+mc26.2 adapter. Keep private storage details out of deferred renderer code. */
26
@Pseudo
27
@Mixin(value = QueuedSectionStorage.class, remap = false)
28
public abstract class SodiumQueuedSectionStorageMixin implements SodiumSectionStorageView {
29
    @Shadow @Final
30
    private Long2ReferenceMap<RenderSection> sections;
31
32
    @Shadow @Final
33
    private Long2ReferenceMap<RenderSection> queuedPuts;
34
35
    @Shadow @Final
36
    private LongSet queuedRemovals;
37
38
    @Shadow
39
    private boolean isQueueing;
40
41
    @Unique
42
    private long combatant$structuralRevision;
43
44
    @Unique
45
    private boolean combatant$applyChangesOnSafeReadEnd;
46
47
    @Override
48
    public Iterable<RenderSection> combatant$sections() {
49
        return sections.values();
50
    }
51
52
    @Override
53
    public long combatant$structuralRevision() {
54
        return combatant$structuralRevision;
55
    }
56
57
    @Inject(method = "queuePut", at = @At("RETURN"), remap = false)
58
    private void combatant$revisionAfterDirectPut(long key, RenderSection section, CallbackInfo ci) {
59
        // When Sodium is in its safe-read phase this write is only queued; revision is advanced
60
        // after endSafeReadPhase actually applies the topology mutation.
61
        if (!isQueueing) combatant$structuralRevision++;
62
    }
63
64
    @Inject(method = "queueRemove", at = @At("RETURN"), remap = false)
65
    private void combatant$revisionAfterDirectRemove(long key, CallbackInfoReturnable<RenderSection> cir) {
66
        if (!isQueueing && cir.getReturnValue() != null) combatant$structuralRevision++;
67
    }
68
69
    @Inject(method = "endSafeReadPhase", at = @At("HEAD"), remap = false)
70
    private void combatant$captureQueuedTopologyChange(CallbackInfo ci) {
71
        combatant$applyChangesOnSafeReadEnd = isQueueing
72
                && (!queuedPuts.isEmpty() || !queuedRemovals.isEmpty());
73
    }
74
75
    @Inject(method = "endSafeReadPhase", at = @At("RETURN"), remap = false)
76
    private void combatant$revisionAfterQueuedChanges(CallbackInfo ci) {
77
        if (combatant$applyChangesOnSafeReadEnd) {
78
            combatant$structuralRevision++;
79
            combatant$applyChangesOnSafeReadEnd = false;
80
        }
81
    }
82
83
    @Inject(method = "deleteAll", at = @At("RETURN"), remap = false)
84
    private void combatant$revisionAfterDeleteAll(CallbackInfo ci) {
85
        combatant$structuralRevision++;
86
    }
87
}
88
SodiumRenderSectionManagerAccessorsrc/main/java/combatant/client/mixins/sodium/SodiumRenderSectionManagerAccessor.javaJava · 23 lines · 782 B
@Mixin(value = RenderSectionManager.class, remap = false)remap=false
ModifiesRenderSectionManager external mod
SodiumRenderSectionManagerAccessor.javaJava · 23 lines · 782 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
11
import net.caffeinemc.mods.sodium.client.render.chunk.storage.SectionStorage;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Pseudo;
14
import org.spongepowered.asm.mixin.gen.Accessor;
15
16
/** Sodium 0.9.1+mc26.2 bridge to the section storage owned by RenderSectionManager. */
17
@Pseudo
18
@Mixin(value = RenderSectionManager.class, remap = false)
19
public interface SodiumRenderSectionManagerAccessor {
20
    @Accessor("renderSections")
21
    SectionStorage combatant$getRenderSections();
22
}
23
SodiumRenderSectionManagerOcclusionMixinsrc/main/java/combatant/client/mixins/sodium/SodiumRenderSectionManagerOcclusionMixin.javaJava · 36 lines · 1.3 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer", remap = false)remap=false
Modifiesnet.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer external mod
SodiumRenderSectionManagerOcclusionMixin.javaJava · 36 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.sugar.Local;
11
import combatant.client.util.render.CameraOcclusionPolicy;
12
import net.minecraft.client.Camera;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Pseudo;
15
import org.spongepowered.asm.mixin.injection.At;
16
import org.spongepowered.asm.mixin.injection.ModifyVariable;
17
18
@Pseudo
19
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer", remap = false)
20
public abstract class SodiumRenderSectionManagerOcclusionMixin {
21
22
    @ModifyVariable(
23
            method = "setupTerrain(Lnet/minecraft/client/Camera;Lnet/caffeinemc/mods/sodium/client/render/viewport/Viewport;Lnet/caffeinemc/mods/sodium/client/util/FogParameters;ZZLorg/joml/Matrix4f;)V",
24
            at = @At("HEAD"),
25
            argsOnly = true,
26
            ordinal = 0
27
    )
28
    private boolean combatant$disableInsideBlockSectionOcclusion(
29
            boolean useOcclusionCulling,
30
            @Local(argsOnly = true) Camera camera
31
    ) {
32
        if (!useOcclusionCulling) return false;
33
        return !CameraOcclusionPolicy.shouldDisableSectionOcclusion(camera);
34
    }
35
}
36
SodiumRenderSectionSurfaceMixinsrc/main/java/combatant/client/mixins/sodium/SodiumRenderSectionSurfaceMixin.javaJava · 28 lines · 1.1 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.RenderSection")
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.RenderSection external mod
SodiumRenderSectionSurfaceMixin.javaJava · 28 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import combatant.client.render.sodium.fluid.WaterSurfaceExtractor;
11
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Pseudo;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
18
/** Keeps extracted patch geometry lifetime identical to Sodium RenderSection lifetime. */
19
@Pseudo
20
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.RenderSection")
21
public abstract class SodiumRenderSectionSurfaceMixin {
22
    @Inject(method = "delete()V", at = @At("HEAD"), remap = false)
23
    private void combatant$discardExtractedSurfaces(CallbackInfo ci) {
24
        RenderSection section = (RenderSection)(Object)this;
25
        WaterSurfaceExtractor.discardSection(section.getPosition().asLong());
26
    }
27
}
28
SodiumShaderChunkRendererMixinsrc/main/java/combatant/client/mixins/sodium/SodiumShaderChunkRendererMixin.javaJava · 236 lines · 10.7 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.ShaderChunkRenderer", remap = false)remap=false
Modifiesnet.caffeinemc.mods.sodium.client.render.chunk.ShaderChunkRenderer external mod
SodiumShaderChunkRendererMixin.javaJava · 236 lines · 10.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.llamalad7.mixinextras.sugar.Local;
13
import com.mojang.blaze3d.PrimitiveTopology;
14
import com.mojang.blaze3d.GpuFormat;
15
import com.mojang.blaze3d.pipeline.ColorTargetState;
16
import com.mojang.blaze3d.pipeline.DepthStencilState;
17
import com.mojang.blaze3d.pipeline.RenderPipeline;
18
import com.mojang.blaze3d.platform.CompareOp;
19
import com.mojang.blaze3d.vertex.VertexFormat;
20
import combatant.client.render.engine.core.CombatantRenderSystem;
21
import combatant.client.render.sodium.SodiumSecondaryTerrainContext;
22
import net.caffeinemc.mods.sodium.client.render.chunk.ShaderChunkRenderer;
23
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses;
24
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
25
import net.minecraft.resources.Identifier;
26
import org.spongepowered.asm.mixin.Final;
27
import org.spongepowered.asm.mixin.Mixin;
28
import org.spongepowered.asm.mixin.Pseudo;
29
import org.spongepowered.asm.mixin.Shadow;
30
import org.spongepowered.asm.mixin.Unique;
31
import org.spongepowered.asm.mixin.injection.At;
32
import org.spongepowered.asm.mixin.injection.Inject;
33
import org.spongepowered.asm.mixin.injection.ModifyArg;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
35
36
import java.util.Map;
37
import java.util.Optional;
38
39
/**
40
 * Sodium 0.9.1 terrain pipeline integration.
41
 *
42
 * <p>Primary terrain can switch between forward/deferred attachment layouts at runtime. Secondary
43
 * views use Combatant-owned pipelines selected by explicit capture purpose, but still reuse
44
 * Sodium's vertex format, bind group and uploaded terrain geometry.</p>
45
 */
46
@Pseudo
47
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.chunk.ShaderChunkRenderer", remap = false)
48
public abstract class SodiumShaderChunkRendererMixin {
49
    @Shadow(remap = false)
50
    @Final
51
    private static Map<TerrainRenderPass, RenderPipeline> programs;
52
53
    @Shadow(remap = false)
54
    @Final
55
    protected VertexFormat vertexFormat;
56
57
    @Unique
58
    private static long combatant$deferredPipelineGeneration = Long.MIN_VALUE;
59
    /**
60
     * Reversed-Z shadow-map raster bias. The shadow atlas clears to 0 and tests GEQUAL, so a
61
     * negative polygon offset moves caster depth away from the light. Applying the slope term at
62
     * rasterization removes the quantized self-shadow stripes that a constant receiver bias cannot
63
     * solve at grazing celestial angles.
64
     */
65
    @Unique
66
    private static final DepthStencilState combatant$shadowDepthState = new DepthStencilState(
67
            CompareOp.GREATER_THAN_OR_EQUAL, true, -1.0f, -1.0f
68
    );
69
    @Unique
70
    private RenderPipeline combatant$shadowSolidPipeline;
71
    @Unique
72
    private RenderPipeline combatant$shadowCutoutPipeline;
73
    @Unique
74
    private RenderPipeline combatant$localShadowSolidPipeline;
75
    @Unique
76
    private RenderPipeline combatant$localShadowCutoutPipeline;
77
    @Unique
78
    private RenderPipeline combatant$reflectionSolidPipeline;
79
    @Unique
80
    private RenderPipeline combatant$reflectionCutoutPipeline;
81
82
    /** Sodium's static primary pipeline cache survives renderer reloads; invalidate on layout generation. */
83
    @Inject(method = "compileProgram", at = @At("HEAD"), remap = false, cancellable = true)
84
    private void combatant$selectCombatantTerrainPipeline(
85
            TerrainRenderPass pass,
86
            CallbackInfoReturnable<RenderPipeline> cir
87
    ) {
88
        SodiumSecondaryTerrainContext.State secondary = SodiumSecondaryTerrainContext.current();
89
        if (secondary != null) {
90
            cir.setReturnValue(switch (secondary.purpose()) {
91
                case SHADOW_DEPTH -> combatant$shadowPipeline(pass, true);
92
                case LOCAL_LIGHT_SHADOW -> combatant$shadowPipeline(pass, false);
93
                case REFLECTION_CAPTURE -> combatant$reflectionPipeline(pass);
94
            });
95
            return;
96
        }
97
98
        long generation = CombatantRenderSystem.deferredWorld().geometryPipelineGeneration();
99
        if (generation == combatant$deferredPipelineGeneration) return;
100
        programs.clear();
101
        combatant$deferredPipelineGeneration = generation;
102
    }
103
104
    @Unique
105
    private RenderPipeline combatant$shadowPipeline(TerrainRenderPass pass, boolean directionalBias) {
106
        if (pass == DefaultTerrainRenderPasses.SOLID) {
107
            if (directionalBias) {
108
                if (combatant$shadowSolidPipeline == null) {
109
                    combatant$shadowSolidPipeline = combatant$createSecondaryPipeline(
110
                            pass, "shadow_solid", true, combatant$shadowDepthState, true);
111
                }
112
                return combatant$shadowSolidPipeline;
113
            }
114
            if (combatant$localShadowSolidPipeline == null) {
115
                combatant$localShadowSolidPipeline = combatant$createSecondaryPipeline(
116
                        pass, "local_shadow_solid", true, DepthStencilState.DEFAULT, false);
117
            }
118
            return combatant$localShadowSolidPipeline;
119
        }
120
        if (pass == DefaultTerrainRenderPasses.CUTOUT) {
121
            if (directionalBias) {
122
                if (combatant$shadowCutoutPipeline == null) {
123
                    combatant$shadowCutoutPipeline = combatant$createSecondaryPipeline(
124
                            pass, "shadow_cutout", true, combatant$shadowDepthState, true);
125
                }
126
                return combatant$shadowCutoutPipeline;
127
            }
128
            if (combatant$localShadowCutoutPipeline == null) {
129
                combatant$localShadowCutoutPipeline = combatant$createSecondaryPipeline(
130
                        pass, "local_shadow_cutout", true, DepthStencilState.DEFAULT, false);
131
            }
132
            return combatant$localShadowCutoutPipeline;
133
        }
134
        throw new IllegalArgumentException("Unsupported shadow terrain pass: " + pass);
135
    }
136
137
    @Unique
138
    private RenderPipeline combatant$reflectionPipeline(TerrainRenderPass pass) {
139
        if (pass == DefaultTerrainRenderPasses.SOLID) {
140
            if (combatant$reflectionSolidPipeline == null) {
141
                combatant$reflectionSolidPipeline = combatant$createSecondaryPipeline(pass, "reflection_solid", false, DepthStencilState.DEFAULT, false);
142
            }
143
            return combatant$reflectionSolidPipeline;
144
        }
145
        if (pass == DefaultTerrainRenderPasses.CUTOUT) {
146
            if (combatant$reflectionCutoutPipeline == null) {
147
                combatant$reflectionCutoutPipeline = combatant$createSecondaryPipeline(pass, "reflection_cutout", false, DepthStencilState.DEFAULT, false);
148
            }
149
            return combatant$reflectionCutoutPipeline;
150
        }
151
        throw new IllegalArgumentException("Unsupported reflection terrain pass: " + pass);
152
    }
153
154
    @Unique
155
    private RenderPipeline combatant$createSecondaryPipeline(TerrainRenderPass pass,
156
                                                              String suffix,
157
                                                              boolean shadowDepth,
158
                                                              DepthStencilState depthStencilState,
159
                                                              boolean distortedDirectionalShadow) {
160
        Identifier sodiumShader = Identifier.fromNamespaceAndPath("sodium", "blocks/block_layer_opaque");
161
        Identifier shader = CombatantRenderSystem.sodium().shaderWorkarounds().overrideShaderIdentifier(sodiumShader);
162
        RenderPipeline.Builder builder = RenderPipeline.builder()
163
                .withBindGroupLayout(ShaderChunkRenderer.BIND_GROUP)
164
                .withLocation(Identifier.fromNamespaceAndPath("combatant", "sodium/" + suffix))
165
                .withCull(true)
166
                .withVertexShader(shader)
167
                .withFragmentShader(shader)
168
                .withDepthStencilState(depthStencilState)
169
                .withPrimitiveTopology(PrimitiveTopology.QUADS)
170
                .withVertexBinding(0, vertexFormat)
171
                .withColorTargetState(shadowDepth
172
                        ? ColorTargetState.DEFAULT
173
                        : new ColorTargetState(Optional.empty(), GpuFormat.RGBA16_FLOAT, ColorTargetState.WRITE_ALL))
174
                .withShaderDefine("USE_VERTEX_COMPRESSION")
175
                .withShaderDefine("USE_FOG");
176
        if (shadowDepth) {
177
            builder.withShaderDefine("COMBATANT_SHADOW_PASS");
178
        }
179
        if (distortedDirectionalShadow) {
180
            builder.withShaderDefine("COMBATANT_DIRECTIONAL_SHADOW_DISTORTION");
181
        }
182
        if (pass.supportsFragmentDiscard()) {
183
            builder.withShaderDefine("ALPHA_CUTOUT", 0.5f);
184
        }
185
        return builder.build();
186
    }
187
188
    @WrapOperation(
189
            method = "createShader",
190
            at = @At(
191
                    value = "INVOKE",
192
                    target = "Lcom/mojang/blaze3d/pipeline/RenderPipeline$Builder;build()Lcom/mojang/blaze3d/pipeline/RenderPipeline;"
193
            )
194
    )
195
    private RenderPipeline combatant$configureDeferredTerrainPipeline(
196
            RenderPipeline.Builder builder,
197
            Operation<RenderPipeline> original,
198
            @Local(argsOnly = true) TerrainRenderPass pass
199
    ) {
200
        if (!pass.isTranslucent() && !SodiumSecondaryTerrainContext.active()) {
201
            CombatantRenderSystem.deferredWorld().configureGeometryPipeline(builder);
202
        }
203
        return original.call(builder);
204
    }
205
206
    @ModifyArg(
207
            method = "createShader",
208
            at = @At(
209
                    value = "INVOKE",
210
                    target = "Lcom/mojang/blaze3d/pipeline/RenderPipeline$Builder;withVertexShader(Lnet/minecraft/resources/Identifier;)Lcom/mojang/blaze3d/pipeline/RenderPipeline$Builder;"
211
            ),
212
            index = 0
213
    )
214
    private Identifier combatant$useCombatantSodiumVertexShader(Identifier original) {
215
        if (!CombatantRenderSystem.deferredWorld().enabled()) {
216
            return original;
217
        }
218
        return CombatantRenderSystem.sodium().shaderWorkarounds().overrideShaderIdentifier(original);
219
    }
220
221
    @ModifyArg(
222
            method = "createShader",
223
            at = @At(
224
                    value = "INVOKE",
225
                    target = "Lcom/mojang/blaze3d/pipeline/RenderPipeline$Builder;withFragmentShader(Lnet/minecraft/resources/Identifier;)Lcom/mojang/blaze3d/pipeline/RenderPipeline$Builder;"
226
            ),
227
            index = 0
228
    )
229
    private Identifier combatant$useCombatantSodiumFragmentShader(Identifier original) {
230
        if (!CombatantRenderSystem.deferredWorld().enabled()) {
231
            return original;
232
        }
233
        return CombatantRenderSystem.sodium().shaderWorkarounds().overrideShaderIdentifier(original);
234
    }
235
}
236
SodiumSortedRenderListsInvokersrc/main/java/combatant/client/mixins/sodium/SodiumSortedRenderListsInvoker.javaJava · 25 lines · 813 B
@Mixin(value = SortedRenderLists.class, remap = false)remap=false
ModifiesSortedRenderLists external mod
SodiumSortedRenderListsInvoker.javaJava · 25 lines · 813 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
11
import net.caffeinemc.mods.sodium.client.render.chunk.lists.ChunkRenderList;
12
import net.caffeinemc.mods.sodium.client.render.chunk.lists.SortedRenderLists;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Pseudo;
15
import org.spongepowered.asm.mixin.gen.Invoker;
16
17
@Pseudo
18
@Mixin(value = SortedRenderLists.class, remap = false)
19
public interface SodiumSortedRenderListsInvoker {
20
    @Invoker("<init>")
21
    static SortedRenderLists combatant$create(ObjectArrayList<ChunkRenderList> lists) {
22
        throw new AssertionError();
23
    }
24
}
25
SodiumVertexConsumerTrackerMixinsrc/main/java/combatant/client/mixins/sodium/SodiumVertexConsumerTrackerMixin.javaJava · 46 lines · 1.6 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerTracker", remap = false)remap=false
Modifiesnet.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerTracker external mod
SodiumVertexConsumerTrackerMixin.javaJava · 46 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import org.slf4j.Logger;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.Pseudo;
13
import org.spongepowered.asm.mixin.Unique;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.Redirect;
16
import combatant.client.util.logging.DebugLog;
17
18
@Pseudo
19
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerTracker", remap = false)
20
public abstract class SodiumVertexConsumerTrackerMixin {
21
    @Redirect(
22
            method = "logBadConsumer",
23
            at = @At(
24
                    value = "INVOKE",
25
                    target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V",
26
                    remap = false
27
            ),
28
            remap = false
29
    )
30
    private static void combatant$redirectBadConsumerWarn(Logger logger, String message, Object arg) {
31
        DebugLog.warn("[Sodium] %s", combatant$formatSlf4jSingleArg(message, arg));
32
    }
33
34
    @Unique
35
    private static String combatant$formatSlf4jSingleArg(String message, Object arg) {
36
        String safeMessage = String.valueOf(message);
37
        int placeholder = safeMessage.indexOf("{}");
38
        if (placeholder < 0) {
39
            return safeMessage + " " + arg;
40
        }
41
        return safeMessage.substring(0, placeholder)
42
                + arg
43
                + safeMessage.substring(placeholder + 2);
44
    }
45
}
46
SodiumWorldRendererFreecamMixinsrc/main/java/combatant/client/mixins/sodium/SodiumWorldRendererFreecamMixin.javaJava · 34 lines · 1.2 KB
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer", remap = false)remap=false
Modifiesnet.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer external mod
SodiumWorldRendererFreecamMixin.javaJava · 34 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import combatant.client.features.module.Modules;
11
import combatant.client.features.module.modules.visuals.Freecam;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Pseudo;
14
import org.spongepowered.asm.mixin.injection.At;
15
import org.spongepowered.asm.mixin.injection.ModifyVariable;
16
17
@Pseudo
18
@Mixin(targets = "net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer", remap = false)
19
public abstract class SodiumWorldRendererFreecamMixin {
20
21
    @ModifyVariable(
22
            method = "setupTerrain(Lnet/minecraft/client/Camera;Lnet/caffeinemc/mods/sodium/client/render/viewport/Viewport;Lnet/caffeinemc/mods/sodium/client/util/FogParameters;ZZLorg/joml/Matrix4f;)V",
23
            at = @At("HEAD"),
24
            argsOnly = true,
25
            ordinal = 0
26
    )
27
    private boolean combatant$freecamDisablesSectionOcclusion(boolean useOcclusionCulling) {
28
        if (!useOcclusionCulling) return false;
29
30
        Freecam freecam = Modules.get(Freecam.class);
31
        return freecam == null || !freecam.isEnabled() || freecam.camEntity == null;
32
    }
33
}
34
SodiumWorldRendererTerrainMixinsrc/main/java/combatant/client/mixins/sodium/SodiumWorldRendererTerrainMixin.javaJava · 173 lines · 10.1 KB
@Mixin(value = SodiumWorldRenderer.class, remap = false)remap=false
ModifiesSodiumWorldRenderer external mod
SodiumWorldRendererTerrainMixin.javaJava · 173 lines · 10.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.sodium;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import com.mojang.blaze3d.systems.RenderSystem;
13
import com.mojang.blaze3d.textures.GpuSampler;
14
import com.mojang.blaze3d.textures.FilterMode;
15
import combatant.client.render.engine.core.CombatantRenderSystem;
16
import combatant.client.render.engine.deferred.DeferredWorldPipeline;
17
import combatant.client.render.sodium.SodiumSecondaryTerrainContext;
18
import combatant.client.render.sodium.SodiumWorldVisibilityView;
19
import net.minecraft.client.Camera;
20
import net.minecraft.world.phys.AABB;
21
import net.caffeinemc.mods.sodium.client.render.viewport.Viewport;
22
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
23
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
24
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
25
import net.caffeinemc.mods.sodium.client.render.chunk.UniformBufferManager;
26
import net.caffeinemc.mods.sodium.client.render.chunk.lists.SortedRenderLists;
27
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses;
28
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
29
import net.caffeinemc.mods.sodium.client.util.FogParameters;
30
import org.spongepowered.asm.mixin.Mixin;
31
import org.spongepowered.asm.mixin.Shadow;
32
import org.spongepowered.asm.mixin.injection.At;
33
import org.spongepowered.asm.mixin.injection.Inject;
34
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35
36
/**
37
 * Captures Sodium's exact terrain pass boundary without cancelling or replacing the production draw.
38
 */
39
@Mixin(value = SodiumWorldRenderer.class, remap = false)
40
public abstract class SodiumWorldRendererTerrainMixin implements SodiumWorldVisibilityView {
41
    @Shadow(remap = false)
42
    public abstract boolean isBoxVisible(double minX, double minY, double minZ,
43
                                         double maxX, double maxY, double maxZ);
44
45
    @Override
46
    public boolean combatant$isBoxVisible(AABB box) {
47
        return isBoxVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
48
    }
49
50
    @Inject(method = "setupTerrain(Lnet/minecraft/client/Camera;Lnet/caffeinemc/mods/sodium/client/render/viewport/Viewport;Lnet/caffeinemc/mods/sodium/client/util/FogParameters;ZZLorg/joml/Matrix4f;)V", at = @At("HEAD"), remap = false)
51
    private void combatant$primaryVisibilityPending(Camera camera,
52
                                                    Viewport viewport,
53
                                                    FogParameters fog,
54
                                                    boolean useOcclusionCulling,
55
                                                    boolean updateChunksImmediately,
56
                                                    org.joml.Matrix4f projection,
57
                                                    CallbackInfo ci) {
58
        CombatantRenderSystem.sodium().markPrimaryVisibilityPending();
59
    }
60
61
    @Inject(method = "setupTerrain(Lnet/minecraft/client/Camera;Lnet/caffeinemc/mods/sodium/client/render/viewport/Viewport;Lnet/caffeinemc/mods/sodium/client/util/FogParameters;ZZLorg/joml/Matrix4f;)V", at = @At("RETURN"), remap = false)
62
    private void combatant$primaryVisibilityReady(Camera camera,
63
                                                  Viewport viewport,
64
                                                  FogParameters fog,
65
                                                  boolean useOcclusionCulling,
66
                                                  boolean updateChunksImmediately,
67
                                                  org.joml.Matrix4f projection,
68
                                                  CallbackInfo ci) {
69
        CombatantRenderSystem.sodium().markPrimaryVisibilityReady();
70
    }
71
    @Inject(method = "renderLayer(Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;DDDLnet/caffeinemc/mods/sodium/client/util/FogParameters;Lcom/mojang/blaze3d/textures/GpuSampler;)V", at = @At("HEAD"), remap = false)
72
    private void combatant$beforeTerrainLayer(ChunkRenderMatrices matrices,
73
                                              TerrainRenderPass pass,
74
                                              double cameraX,
75
                                              double cameraY,
76
                                              double cameraZ,
77
                                              FogParameters fog,
78
                                              GpuSampler sampler,
79
                                              CallbackInfo ci) {
80
        if (SodiumSecondaryTerrainContext.active()) return;
81
        CombatantRenderSystem.sodium().terrainInterop().beforeTerrainDraw(
82
                matrices, pass, cameraX, cameraY, cameraZ, fog, sampler);
83
        if (pass == DefaultTerrainRenderPasses.TRANSLUCENT) {
84
            CombatantRenderSystem.deferredWorld().beforeTranslucency(
85
                    pass.getTarget().getColorTextureView(),
86
                    pass.getTarget().getDepthTextureView()
87
            );
88
        } else {
89
            CombatantRenderSystem.deferredWorld().beforeTerrainSubmission();
90
        }
91
    }
92
93
    /**
94
     * Own Sodium's once-per-frame terrain UBO at the exact update boundary.
95
     *
96
     * <p>Combatant can recursively submit arbitrary secondary cameras before any primary terrain
97
     * layer. The transaction is therefore keyed to logical view ownership, not to SOLID/shadow/
98
     * reflection ordering. DynamicUniformStorage keeps previously returned slices alive until
99
     * Sodium endFrame(), so re-arming update() allocates/reuses a value-correct slice without
100
     * overwriting an already submitted draw.</p>
101
     */
102
    @WrapOperation(
103
            method = "renderLayer(Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;DDDLnet/caffeinemc/mods/sodium/client/util/FogParameters;Lcom/mojang/blaze3d/textures/GpuSampler;)V",
104
            at = @At(
105
                    value = "INVOKE",
106
                    target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/UniformBufferManager;update(Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lnet/caffeinemc/mods/sodium/client/util/FogParameters;)V"
107
            ),
108
            remap = false
109
    )
110
    private void combatant$terrainUniformTransaction(UniformBufferManager manager,
111
                                                      ChunkRenderMatrices matrices,
112
                                                      FogParameters fog,
113
                                                      Operation<Void> original) {
114
        SodiumSecondaryTerrainContext.State secondary = SodiumSecondaryTerrainContext.current();
115
        boolean reload = secondary != null
116
                ? secondary.beginTerrainUniformUpdate()
117
                : SodiumSecondaryTerrainContext.primaryUniformsDirty();
118
        if (reload) manager.prepareFrame();
119
120
        boolean success = false;
121
        try {
122
            original.call(manager, matrices, fog);
123
            success = true;
124
        } finally {
125
            if (secondary != null) {
126
                secondary.finishTerrainUniformUpdate(reload, success);
127
            } else {
128
                SodiumSecondaryTerrainContext.finishPrimaryUniformUpdate(reload, success);
129
            }
130
        }
131
    }
132
133
    @Inject(method = "renderLayer(Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;DDDLnet/caffeinemc/mods/sodium/client/util/FogParameters;Lcom/mojang/blaze3d/textures/GpuSampler;)V", at = @At("RETURN"), remap = false)
134
    private void combatant$afterTerrainLayer(ChunkRenderMatrices matrices,
135
                                             TerrainRenderPass pass,
136
                                             double cameraX,
137
                                             double cameraY,
138
                                             double cameraZ,
139
                                             FogParameters fog,
140
                                             GpuSampler sampler,
141
                                             CallbackInfo ci) {
142
        if (SodiumSecondaryTerrainContext.active()) return;
143
        if (pass == DefaultTerrainRenderPasses.CUTOUT && CombatantRenderSystem.deferredWorld().enabled()) {
144
            DeferredWorldPipeline.LightingState lighting = new DeferredWorldPipeline.LightingState(
145
                    fog.red(), fog.green(), fog.blue(), fog.alpha(),
146
                    fog.environmentalStart(), fog.environmentalEnd(),
147
                    fog.renderStart(), fog.renderEnd()
148
            );
149
            CombatantRenderSystem.deferredWorld().resolveLighting(
150
                    pass.getTarget().getColorTextureView(),
151
                    RenderSystem.getSamplerCache().getClampToEdge(FilterMode.NEAREST),
152
                    lighting
153
            );
154
        }
155
        CombatantRenderSystem.sodium().terrainInterop().afterTerrainDraw(
156
                matrices, pass, cameraX, cameraY, cameraZ, fog, sampler);
157
    }
158
    @WrapOperation(
159
            method = "renderLayer(Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;DDDLnet/caffeinemc/mods/sodium/client/util/FogParameters;Lcom/mojang/blaze3d/textures/GpuSampler;)V",
160
            at = @At(
161
                    value = "INVOKE",
162
                    target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager;getRenderLists()Lnet/caffeinemc/mods/sodium/client/render/chunk/lists/SortedRenderLists;"
163
            ),
164
            remap = false
165
    )
166
    private SortedRenderLists combatant$secondaryRenderLists(RenderSectionManager manager,
167
                                                              Operation<SortedRenderLists> original) {
168
        SodiumSecondaryTerrainContext.State secondary = SodiumSecondaryTerrainContext.current();
169
        return secondary != null ? secondary.renderLists(manager) : original.call(manager);
170
    }
171
172
}
173
AbstractWaypointRenderProviderMixinsrc/main/java/combatant/client/mixins/xaero/minimap/AbstractWaypointRenderProviderMixin.javaJava · 69 lines · 3.0 KB
@Mixin(AbstractWaypointRenderProvider.class)
ModifiesAbstractWaypointRenderProvider external mod
AbstractWaypointRenderProviderMixin.javaJava · 69 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.xaero.minimap;
9
10
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
11
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
12
import org.spongepowered.asm.mixin.Mixin;
13
import org.spongepowered.asm.mixin.Pseudo;
14
import org.spongepowered.asm.mixin.injection.At;
15
import combatant.client.compat.xaero.XaeroIntegration;
16
import combatant.client.compat.xaero.XaeroWaypointHudOverlay;
17
import combatant.client.compat.xaero.XaeroMinimapIntegration;
18
import xaero.common.minimap.waypoints.Waypoint;
19
import xaero.hud.minimap.element.render.MinimapElementRenderLocation;
20
import xaero.hud.minimap.waypoint.WaypointCollector;
21
import xaero.hud.minimap.waypoint.render.AbstractWaypointRenderContext;
22
import xaero.hud.minimap.waypoint.render.AbstractWaypointRenderProvider;
23
import xaero.hud.minimap.waypoint.render.WaypointMapRenderContext;
24
import xaero.hud.minimap.waypoint.render.world.WaypointWorldRenderContext;
25
26
import java.util.List;
27
28
@Pseudo
29
@Mixin(AbstractWaypointRenderProvider.class)
30
public abstract class AbstractWaypointRenderProviderMixin {
31
32
    @WrapOperation(
33
            method = "begin*",
34
            at = @At(
35
                    value = "INVOKE",
36
                    target = "Lxaero/hud/minimap/waypoint/WaypointCollector;collect(Ljava/util/List;)V"
37
            )
38
    )
39
    private void combatant$addWaypoints(WaypointCollector instance,
40
                                        List<Waypoint> destination,
41
                                        Operation<Void> original,
42
                                        MinimapElementRenderLocation location,
43
                                        AbstractWaypointRenderContext context) {
44
        if (context instanceof WaypointWorldRenderContext
45
                && XaeroWaypointHudOverlay.shouldSuppressNativeXaeroWaypoints()) {
46
            // Keep Xaero's collector lifecycle intact, but discard only the entries appended by it.
47
            // Combatant's world marker overlay reads the same session independently, so leaving the
48
            // provider list populated would render both Xaero's native waypoint and our marker.
49
            int existing = destination.size();
50
            original.call(instance, destination);
51
            if (destination.size() > existing) {
52
                destination.subList(existing, destination.size()).clear();
53
            }
54
            return;
55
        }
56
57
        XaeroIntegration.RenderTarget target = null;
58
        if (context instanceof WaypointWorldRenderContext) {
59
            target = XaeroIntegration.RenderTarget.WORLD_HUD;
60
        } else if (context instanceof WaypointMapRenderContext) {
61
            target = XaeroIntegration.RenderTarget.MINIMAP;
62
        }
63
        if (target != null) {
64
            destination.addAll(XaeroMinimapIntegration.waypoints(target));
65
        }
66
        original.call(instance, destination);
67
    }
68
}
69
WaypointRenderProviderMixinsrc/main/java/combatant/client/mixins/xaero/worldmap/WaypointRenderProviderMixin.javaJava · 78 lines · 2.9 KB
@Mixin(WaypointRenderProvider.class)
ModifiesWaypointRenderProvider external mod
WaypointRenderProviderMixin.javaJava · 78 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.xaero.worldmap;
9
10
import org.spongepowered.asm.mixin.*;
11
import org.spongepowered.asm.mixin.injection.At;
12
import org.spongepowered.asm.mixin.injection.Inject;
13
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15
import combatant.client.compat.xaero.XaeroWorldMapIntegration;
16
import xaero.map.element.render.ElementRenderLocation;
17
import xaero.map.mods.SupportXaeroMinimap;
18
import xaero.map.mods.gui.Waypoint;
19
import xaero.map.mods.gui.WaypointRenderContext;
20
import xaero.map.mods.gui.WaypointRenderProvider;
21
22
import java.util.ArrayDeque;
23
import java.util.Queue;
24
25
@Pseudo
26
@Mixin(WaypointRenderProvider.class)
27
public final class WaypointRenderProviderMixin {
28
29
    @Shadow
30
    @Final
31
    private SupportXaeroMinimap minimap;
32
33
    @Unique
34
    private Queue<Waypoint> combatant$pendingWaypoints;
35
36
    @Unique
37
    private boolean combatant$originalHadNext;
38
39
    @Inject(method = "begin*", at = @At("HEAD"))
40
    private void combatant$begin(ElementRenderLocation location,
41
                                 WaypointRenderContext context,
42
                                 CallbackInfo ci) {
43
        combatant$pendingWaypoints = new ArrayDeque<>();
44
        combatant$pendingWaypoints.addAll(XaeroWorldMapIntegration.waypoints(minimap));
45
        combatant$originalHadNext = false;
46
    }
47
48
    @Inject(method = "hasNext*", at = @At("RETURN"), cancellable = true)
49
    private void combatant$hasNext(ElementRenderLocation location,
50
                                   WaypointRenderContext context,
51
                                   CallbackInfoReturnable<Boolean> cir) {
52
        combatant$originalHadNext = cir.getReturnValue();
53
        cir.setReturnValue(combatant$originalHadNext
54
                || (combatant$pendingWaypoints != null && !combatant$pendingWaypoints.isEmpty()));
55
    }
56
57
    @Inject(method = "getNext*", at = @At("HEAD"), cancellable = true)
58
    private void combatant$getNext(ElementRenderLocation location,
59
                                   WaypointRenderContext context,
60
                                   CallbackInfoReturnable<Waypoint> cir) {
61
        if (combatant$originalHadNext) {
62
            combatant$originalHadNext = false;
63
            return;
64
        }
65
        if (combatant$pendingWaypoints != null && !combatant$pendingWaypoints.isEmpty()) {
66
            cir.setReturnValue(combatant$pendingWaypoints.poll());
67
        }
68
    }
69
70
    @Inject(method = "end*", at = @At("HEAD"))
71
    private void combatant$end(ElementRenderLocation location,
72
                               WaypointRenderContext context,
73
                               CallbackInfo ci) {
74
        combatant$pendingWaypoints = null;
75
        combatant$originalHadNext = false;
76
    }
77
}
78
WorldMapWaypointAccessorsrc/main/java/combatant/client/mixins/xaero/worldmap/WorldMapWaypointAccessor.javaJava · 31 lines · 613 B
@Mixin(Waypoint.class)
ModifiesWaypoint
WorldMapWaypointAccessor.javaJava · 31 lines · 613 B · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.mixins.xaero.worldmap;
9
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.Pseudo;
12
import org.spongepowered.asm.mixin.gen.Accessor;
13
import xaero.map.mods.gui.Waypoint;
14
15
@Pseudo
16
@Mixin(Waypoint.class)
17
public interface WorldMapWaypointAccessor {
18
19
    @Accessor
20
    void setX(int x);
21
22
    @Accessor
23
    void setY(int y);
24
25
    @Accessor
26
    void setZ(int z);
27
28
    @Accessor
29
    void setColor(int color);
30
}
31
CommandEncoderDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/CommandEncoderDiagnosticsMixin.javaJava · 92 lines · 5.4 KB
@Mixin(CommandEncoder.class)
CommandEncoderDiagnosticsMixin.javaJava · 92 lines · 5.4 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.systems.CommandEncoder;
4
import com.mojang.blaze3d.systems.RenderPass;
5
import com.mojang.blaze3d.systems.RenderPassDescriptor;
6
import com.mojang.blaze3d.systems.RenderSystem;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.Unique;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
14
15
@Mixin(CommandEncoder.class)
16
public abstract class CommandEncoderDiagnosticsMixin {
17
    @Unique
18
    private static boolean combatant$isVulkanBackend() {
19
        try {
20
            if (RenderSystem.getDevice() == null || RenderSystem.getDevice().getDeviceInfo() == null) return false;
21
            String backendName = RenderSystem.getDevice().getDeviceInfo().backendName();
22
            return backendName != null && backendName.toLowerCase(java.util.Locale.ROOT).contains("vulkan");
23
        } catch (Throwable ignored) {
24
            return false;
25
        }
26
    }
27
28
    @Unique
29
    private static String combatant$label(RenderPassDescriptor descriptor) {
30
        if (descriptor == null || descriptor.label() == null) return "<null-label>";
31
        try {
32
            String label = descriptor.label().get();
33
            return label == null ? "<null-label>" : label;
34
        } catch (Throwable t) {
35
            return "<label-error:" + t.getClass().getSimpleName() + ">";
36
        }
37
    }
38
39
    @Inject(method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;", at = @At("HEAD"))
40
    private void combatant$wrapperCreateHead(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPass> cir) {
41
        if (!combatant$isVulkanBackend()) return;
42
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.create.head",
43
                "label", combatant$label(descriptor),
44
                "colors", descriptor == null || descriptor.colorAttachments() == null ? -1 : descriptor.colorAttachments().size(),
45
                "depth", descriptor != null && descriptor.depthAttachment() != null);
46
    }
47
48
    @Inject(method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPassBackend;", shift = At.Shift.BEFORE))
49
    private void combatant$backendCreateBefore(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPass> cir) {
50
        if (!combatant$isVulkanBackend()) return;
51
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.backend.create.before", "label", combatant$label(descriptor));
52
    }
53
54
    @Inject(method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPassBackend;", shift = At.Shift.AFTER))
55
    private void combatant$backendCreateAfter(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPass> cir) {
56
        if (!combatant$isVulkanBackend()) return;
57
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.backend.create.after", "label", combatant$label(descriptor));
58
    }
59
60
    @Inject(method = "createRenderPass(Lcom/mojang/blaze3d/systems/RenderPassDescriptor;)Lcom/mojang/blaze3d/systems/RenderPass;", at = @At("RETURN"))
61
    private void combatant$wrapperCreateReturn(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPass> cir) {
62
        if (!combatant$isVulkanBackend()) return;
63
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.create.return",
64
                "label", combatant$label(descriptor),
65
                "pass", cir.getReturnValue() == null ? "<null>" : cir.getReturnValue().getClass().getName());
66
    }
67
68
    @Inject(method = "submitRenderPass", at = @At("HEAD"))
69
    private void combatant$wrapperSubmitHead(CallbackInfo ci) {
70
        if (!combatant$isVulkanBackend()) return;
71
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.submit.head");
72
    }
73
74
    @Inject(method = "submitRenderPass", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;submitRenderPass()V", shift = At.Shift.BEFORE))
75
    private void combatant$backendSubmitBefore(CallbackInfo ci) {
76
        if (!combatant$isVulkanBackend()) return;
77
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.backend.submit.before");
78
    }
79
80
    @Inject(method = "submitRenderPass", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoderBackend;submitRenderPass()V", shift = At.Shift.AFTER))
81
    private void combatant$backendSubmitAfter(CallbackInfo ci) {
82
        if (!combatant$isVulkanBackend()) return;
83
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.backend.submit.after");
84
    }
85
86
    @Inject(method = "submitRenderPass", at = @At("TAIL"))
87
    private void combatant$wrapperSubmitTail(CallbackInfo ci) {
88
        if (!combatant$isVulkanBackend()) return;
89
        VulkanCrashDiagnostics.breadcrumbQuiet("commandencoder.wrapper.submit.tail");
90
    }
91
}
92
RenderPassWrapperDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/RenderPassWrapperDiagnosticsMixin.javaJava · 84 lines · 3.8 KB
@Mixin(RenderPass.class)
ModifiesRenderPass
RenderPassWrapperDiagnosticsMixin.javaJava · 84 lines · 3.8 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.pipeline.RenderPipeline;
4
import com.mojang.blaze3d.systems.RenderPass;
5
import com.mojang.blaze3d.systems.RenderSystem;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.Unique;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.Inject;
10
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
12
13
@Mixin(RenderPass.class)
14
public abstract class RenderPassWrapperDiagnosticsMixin {
15
    @Unique
16
    private static boolean combatant$isVulkanBackend() {
17
        try {
18
            if (RenderSystem.getDevice() == null || RenderSystem.getDevice().getDeviceInfo() == null) return false;
19
            String backendName = RenderSystem.getDevice().getDeviceInfo().backendName();
20
            return backendName != null && backendName.toLowerCase(java.util.Locale.ROOT).contains("vulkan");
21
        } catch (Throwable ignored) {
22
            return false;
23
        }
24
    }
25
26
    @Unique
27
    private static String combatant$pipelineId(RenderPipeline pipeline) {
28
        if (pipeline == null) return "<null>";
29
        try {
30
            return String.valueOf(pipeline.getLocation());
31
        } catch (Throwable ignored) {
32
            return pipeline.toString();
33
        }
34
    }
35
36
    @Inject(method = "setPipeline", at = @At("HEAD"))
37
    private void combatant$setPipelineHead(RenderPipeline pipeline, CallbackInfo ci) {
38
        if (!combatant$isVulkanBackend()) return;
39
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.setpipeline.head", "pipeline", combatant$pipelineId(pipeline));
40
    }
41
42
    @Inject(
43
            method = "setPipeline",
44
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderPassBackend;setPipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;)V", shift = At.Shift.BEFORE)
45
    )
46
    private void combatant$backendSetPipelineBefore(RenderPipeline pipeline, CallbackInfo ci) {
47
        if (!combatant$isVulkanBackend()) return;
48
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.backend.setpipeline.before", "pipeline", combatant$pipelineId(pipeline));
49
    }
50
51
    @Inject(
52
            method = "setPipeline",
53
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderPassBackend;setPipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;)V", shift = At.Shift.AFTER)
54
    )
55
    private void combatant$backendSetPipelineAfter(RenderPipeline pipeline, CallbackInfo ci) {
56
        if (!combatant$isVulkanBackend()) return;
57
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.backend.setpipeline.after", "pipeline", combatant$pipelineId(pipeline));
58
    }
59
60
    @Inject(method = "close", at = @At("HEAD"))
61
    private void combatant$closeHead(CallbackInfo ci) {
62
        if (!combatant$isVulkanBackend()) return;
63
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.close.head");
64
    }
65
66
    @Inject(method = "close", at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V", shift = At.Shift.BEFORE))
67
    private void combatant$closeOnFinishBefore(CallbackInfo ci) {
68
        if (!combatant$isVulkanBackend()) return;
69
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.close.onfinish.before");
70
    }
71
72
    @Inject(method = "close", at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V", shift = At.Shift.AFTER))
73
    private void combatant$closeOnFinishAfter(CallbackInfo ci) {
74
        if (!combatant$isVulkanBackend()) return;
75
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.close.onfinish.after");
76
    }
77
78
    @Inject(method = "close", at = @At("TAIL"))
79
    private void combatant$closeTail(CallbackInfo ci) {
80
        if (!combatant$isVulkanBackend()) return;
81
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.wrapper.close.tail");
82
    }
83
}
84
VulkanBackendMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanBackendMixin.javaJava · 17 lines · 681 B
@Mixin(VulkanBackend.class)
VulkanBackendMixin.javaJava · 17 lines · 681 B · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.shaders.GpuDebugOptions;
4
import com.mojang.blaze3d.vulkan.VulkanBackend;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.injection.At;
7
import org.spongepowered.asm.mixin.injection.ModifyVariable;
8
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
9
10
@Mixin(VulkanBackend.class)
11
public abstract class VulkanBackendMixin {
12
    @ModifyVariable(method = "createDevice", at = @At("HEAD"), argsOnly = true)
13
    private GpuDebugOptions combatant$forceDebugOptions(GpuDebugOptions options) {
14
        return VulkanCrashDiagnostics.forceDebugOptions(options);
15
    }
16
}
17
VulkanCheckpointDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanCheckpointDiagnosticsMixin.javaJava · 36 lines · 1.7 KB
@Mixin(targets = "com.mojang.blaze3d.vulkan.checkpoints.AbstractCheckpointStorage")
VulkanCheckpointDiagnosticsMixin.javaJava · 36 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.vulkan.checkpoints.CheckpointExtension;
4
import org.lwjgl.vulkan.VkCommandBuffer;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.injection.At;
7
import org.spongepowered.asm.mixin.injection.Inject;
8
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
10
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
11
12
import java.util.function.Supplier;
13
14
@Mixin(targets = "com.mojang.blaze3d.vulkan.checkpoints.AbstractCheckpointStorage")
15
public abstract class VulkanCheckpointDiagnosticsMixin {
16
    @Inject(method = "recordCheckpoint(Lorg/lwjgl/vulkan/VkCommandBuffer;Lcom/mojang/blaze3d/vulkan/checkpoints/CheckpointExtension$CheckpointType;Ljava/util/function/Supplier;)V", at = @At("HEAD"))
17
    private void combatant$logCheckpoint(VkCommandBuffer commandBuffer,
18
                                         CheckpointExtension.CheckpointType type,
19
                                         Supplier<String> label,
20
                                         CallbackInfo ci) {
21
        VulkanCrashDiagnostics.breadcrumbQuiet(VulkanRenderStateBridge.forceDisableCheckpoints() ? "checkpoint.disabled" : "checkpoint.record",
22
                "type", type,
23
                "label", safeLabel(label),
24
                "commandBuffer", commandBuffer == null ? 0L : commandBuffer.address());
25
    }
26
27
    private static String safeLabel(Supplier<String> label) {
28
        if (label == null) return "<null>";
29
        try {
30
            return label.get();
31
        } catch (Throwable t) {
32
            return "<label-error:" + VulkanCrashDiagnostics.throwable(t) + ">";
33
        }
34
    }
35
}
36
VulkanCommandEncoderDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanCommandEncoderDiagnosticsMixin.javaJava · 95 lines · 5.3 KB
@Mixin(VulkanCommandEncoder.class)
VulkanCommandEncoderDiagnosticsMixin.javaJava · 95 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.llamalad7.mixinextras.sugar.Local;
4
import com.mojang.blaze3d.systems.RenderPassBackend;
5
import com.mojang.blaze3d.systems.RenderPassDescriptor;
6
import com.mojang.blaze3d.vulkan.VulkanCommandEncoder;
7
import org.lwjgl.vulkan.VkRenderingAttachmentInfo;
8
import org.lwjgl.vulkan.VkRenderingInfo;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
import org.spongepowered.asm.mixin.injection.Inject;
12
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
15
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
16
17
@Mixin(VulkanCommandEncoder.class)
18
public abstract class VulkanCommandEncoderDiagnosticsMixin {
19
    @Inject(method = "createRenderPass", at = @At("HEAD"))
20
    private void combatant$renderPassCreateHead(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPassBackend> cir) {
21
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.create.head",
22
                "colors", descriptor == null || descriptor.colorAttachments() == null ? -1 : descriptor.colorAttachments().size(),
23
                "depth", descriptor != null && descriptor.depthAttachment() != null,
24
                "samples", VulkanRenderStateBridge.currentRenderPassSamples(),
25
                "stencil", VulkanRenderStateBridge.currentRenderPassNeedsStencilAttachment());
26
    }
27
28
    @Inject(
29
            method = "createRenderPass",
30
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRDynamicRendering;vkCmdBeginRenderingKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;Lorg/lwjgl/vulkan/VkRenderingInfo;)V", shift = At.Shift.BEFORE)
31
    )
32
    private void combatant$beforeBeginRendering(RenderPassDescriptor descriptor,
33
                                                CallbackInfoReturnable<RenderPassBackend> cir,
34
                                                @Local VkRenderingInfo renderingInfo) {
35
        int colorResolves = 0;
36
        VkRenderingAttachmentInfo.Buffer colors = renderingInfo == null ? null : renderingInfo.pColorAttachments();
37
        if (colors != null) {
38
            for (int i = 0; i < colors.remaining(); i++) {
39
                if (colors.get(i).resolveImageView() != 0L) colorResolves++;
40
            }
41
        }
42
        VkRenderingAttachmentInfo depth = renderingInfo == null ? null : renderingInfo.pDepthAttachment();
43
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.beginrendering.before",
44
                "colors", descriptor == null || descriptor.colorAttachments() == null ? -1 : descriptor.colorAttachments().size(),
45
                "depth", descriptor != null && descriptor.depthAttachment() != null,
46
                "samples", VulkanRenderStateBridge.currentRenderPassSamples(),
47
                "stencil", VulkanRenderStateBridge.currentRenderPassNeedsStencilAttachment(),
48
                "colorResolves", colorResolves,
49
                "depthResolveMode", depth == null ? 0 : depth.resolveMode(),
50
                "depthResolveView", depth == null ? 0L : depth.resolveImageView(),
51
                "renderingInfo", renderingInfo == null ? 0L : renderingInfo.address());
52
    }
53
54
    @Inject(
55
            method = "createRenderPass",
56
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRDynamicRendering;vkCmdBeginRenderingKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;Lorg/lwjgl/vulkan/VkRenderingInfo;)V", shift = At.Shift.AFTER)
57
    )
58
    private void combatant$afterBeginRendering(RenderPassDescriptor descriptor,
59
                                               CallbackInfoReturnable<RenderPassBackend> cir) {
60
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.beginrendering.after");
61
    }
62
63
    @Inject(method = "createRenderPass", at = @At("RETURN"))
64
    private void combatant$renderPassCreated(RenderPassDescriptor descriptor, CallbackInfoReturnable<RenderPassBackend> cir) {
65
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.create.return",
66
                "backend", cir.getReturnValue() == null ? "<null>" : cir.getReturnValue().getClass().getName());
67
    }
68
69
    @Inject(method = "submitRenderPass", at = @At("HEAD"))
70
    private void combatant$submitVulkanRenderPassHead(CallbackInfo ci) {
71
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.submit.head");
72
    }
73
74
    @Inject(
75
            method = "submitRenderPass",
76
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRDynamicRendering;vkCmdEndRenderingKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;)V", shift = At.Shift.BEFORE)
77
    )
78
    private void combatant$beforeEndRendering(CallbackInfo ci) {
79
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.endrendering.before");
80
    }
81
82
    @Inject(
83
            method = "submitRenderPass",
84
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRDynamicRendering;vkCmdEndRenderingKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;)V", shift = At.Shift.AFTER)
85
    )
86
    private void combatant$afterEndRendering(CallbackInfo ci) {
87
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.endrendering.after");
88
    }
89
90
    @Inject(method = "submitRenderPass", at = @At("TAIL"))
91
    private void combatant$submitVulkanRenderPassTail(CallbackInfo ci) {
92
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.submit.tail");
93
    }
94
}
95
VulkanDebugMessageMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanDebugMessageMixin.javaJava · 20 lines · 966 B
@Mixin(targets = "com.mojang.blaze3d.vulkan.VulkanDebug$Enabled")
VulkanDebugMessageMixin.javaJava · 20 lines · 966 B · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import org.spongepowered.asm.mixin.Mixin;
4
import org.spongepowered.asm.mixin.injection.At;
5
import org.spongepowered.asm.mixin.injection.Inject;
6
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
7
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
8
9
@Mixin(targets = "com.mojang.blaze3d.vulkan.VulkanDebug$Enabled")
10
public abstract class VulkanDebugMessageMixin {
11
    @Inject(method = "onDebugMessage", at = @At("HEAD"))
12
    private void combatant$captureDriverDebugMessage(int severity,
13
                                                     int type,
14
                                                     long callbackData,
15
                                                     long userData,
16
                                                     CallbackInfoReturnable<Integer> cir) {
17
        VulkanCrashDiagnostics.driverDebugMessage(severity, type, callbackData);
18
    }
19
}
20
VulkanDeviceDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanDeviceDiagnosticsMixin.javaJava · 31 lines · 1.4 KB
@Mixin(VulkanDevice.class)
ModifiesVulkanDevice
VulkanDeviceDiagnosticsMixin.javaJava · 31 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.shaders.ShaderSource;
4
import com.mojang.blaze3d.vulkan.VulkanDevice;
5
import com.mojang.blaze3d.vulkan.VulkanInstance;
6
import com.mojang.blaze3d.vulkan.VulkanPhysicalDevice;
7
import com.mojang.blaze3d.vulkan.checkpoints.CheckpointExtension;
8
import org.lwjgl.vulkan.VkDevice;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
import org.spongepowered.asm.mixin.injection.Inject;
12
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
14
15
import java.util.Set;
16
17
@Mixin(VulkanDevice.class)
18
public abstract class VulkanDeviceDiagnosticsMixin {
19
    @Inject(method = "<init>", at = @At("RETURN"))
20
    private void combatant$dumpVulkanDevice(ShaderSource shaderSource,
21
                                            VulkanInstance instance,
22
                                            VulkanPhysicalDevice physicalDevice,
23
                                            Set<String> enabledExtensions,
24
                                            VkDevice device,
25
                                            long vma,
26
                                            CheckpointExtension checkpointExtension,
27
                                            CallbackInfo ci) {
28
        VulkanCrashDiagnostics.dumpDevice(instance, physicalDevice, enabledExtensions);
29
    }
30
}
31
VulkanQueueSubmissionMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanQueueSubmissionMixin.javaJava · 28 lines · 1.4 KB
@Mixin(targets = "com.mojang.blaze3d.vulkan.VulkanQueue$Submission")
VulkanQueueSubmissionMixin.javaJava · 28 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import org.lwjgl.vulkan.KHRSynchronization2;
4
import org.lwjgl.vulkan.VkQueue;
5
import org.lwjgl.vulkan.VkSubmitInfo2;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.injection.At;
8
import org.spongepowered.asm.mixin.injection.Redirect;
9
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
10
11
@Mixin(targets = "com.mojang.blaze3d.vulkan.VulkanQueue$Submission")
12
public abstract class VulkanQueueSubmissionMixin {
13
    @Redirect(
14
            method = "close",
15
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRSynchronization2;vkQueueSubmit2KHR(Lorg/lwjgl/vulkan/VkQueue;Lorg/lwjgl/vulkan/VkSubmitInfo2$Buffer;J)I")
16
    )
17
    private int combatant$diagnoseQueueSubmit(VkQueue queue, VkSubmitInfo2.Buffer submits, long fence) {
18
        int submitCount = submits == null ? -1 : submits.remaining();
19
        VulkanCrashDiagnostics.breadcrumbQuiet("queue.submit.before", "submits", submitCount, "fence", fence);
20
        int result = KHRSynchronization2.vkQueueSubmit2KHR(queue, submits, fence);
21
        VulkanCrashDiagnostics.breadcrumbQuiet("queue.submit.after", "result", result, "submits", submitCount, "fence", fence);
22
        if (result != 0) {
23
            VulkanCrashDiagnostics.breadcrumb("queue.submit.failed", "result", result, "submits", submitCount, "fence", fence);
24
        }
25
        return result;
26
    }
27
}
28
VulkanRenderPassDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanRenderPassDiagnosticsMixin.javaJava · 290 lines · 15.0 KB
@Mixin(VulkanRenderPass.class)
VulkanRenderPassDiagnosticsMixin.javaJava · 290 lines · 15.0 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.mojang.blaze3d.IndexType;
4
import com.mojang.blaze3d.buffers.GpuBuffer;
5
import com.mojang.blaze3d.buffers.GpuBufferSlice;
6
import com.mojang.blaze3d.pipeline.RenderPipeline;
7
import com.mojang.blaze3d.systems.RenderPass;
8
import com.mojang.blaze3d.textures.GpuSampler;
9
import com.mojang.blaze3d.textures.GpuTextureView;
10
import com.mojang.blaze3d.vulkan.VulkanCommandEncoder;
11
import com.mojang.blaze3d.vulkan.VulkanDevice;
12
import com.mojang.blaze3d.vulkan.VulkanRenderPass;
13
import com.mojang.blaze3d.vulkan.checkpoints.CheckpointExtension;
14
import org.lwjgl.PointerBuffer;
15
import org.lwjgl.vulkan.VkCommandBuffer;
16
import org.spongepowered.asm.mixin.Mixin;
17
import org.spongepowered.asm.mixin.injection.At;
18
import org.spongepowered.asm.mixin.injection.Inject;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
20
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
21
22
import java.nio.IntBuffer;
23
import java.util.Collection;
24
import java.util.function.Supplier;
25
26
@Mixin(VulkanRenderPass.class)
27
public abstract class VulkanRenderPassDiagnosticsMixin {
28
29
    @Inject(method = "<init>", at = @At("HEAD"))
30
    private static void combatant$ctorHead(VulkanDevice device,
31
                                           VulkanCommandEncoder encoder,
32
                                           VkCommandBuffer commandBuffer,
33
                                           CheckpointExtension.CheckpointStorage checkpointStorage,
34
                                           RenderPass.RenderArea renderArea,
35
                                           int outputWidth,
36
                                           int outputHeight,
37
                                           boolean hasDepth,
38
                                           Supplier<String> label,
39
                                           CallbackInfo ci) {
40
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.object.ctor.head",
41
                "label", labelText(label),
42
                "area", areaText(renderArea),
43
                "output", outputWidth + "x" + outputHeight,
44
                "depth", hasDepth,
45
                "commandBuffer", commandBuffer == null ? 0L : commandBuffer.address());
46
    }
47
48
    @Inject(method = "<init>", at = @At("TAIL"))
49
    private void combatant$ctorTail(VulkanDevice device,
50
                                    VulkanCommandEncoder encoder,
51
                                    VkCommandBuffer commandBuffer,
52
                                    CheckpointExtension.CheckpointStorage checkpointStorage,
53
                                    RenderPass.RenderArea renderArea,
54
                                    int outputWidth,
55
                                    int outputHeight,
56
                                    boolean hasDepth,
57
                                    Supplier<String> label,
58
                                    CallbackInfo ci) {
59
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.object.ctor.tail",
60
                "label", labelText(label),
61
                "area", areaText(renderArea));
62
    }
63
64
65
    @Inject(method = "setPipeline", at = @At("HEAD"))
66
    private void combatant$setPipelineHead(RenderPipeline pipeline, CallbackInfo ci) {
67
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.setpipeline.head", "pipeline", pipelineId(pipeline));
68
    }
69
70
    @Inject(
71
            method = "setPipeline",
72
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vulkan/VulkanDevice;getOrCompilePipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;)Lcom/mojang/blaze3d/vulkan/VulkanRenderPipeline;", shift = At.Shift.BEFORE)
73
    )
74
    private void combatant$compilePipelineBefore(RenderPipeline pipeline, CallbackInfo ci) {
75
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pipeline.get.before", "pipeline", pipelineId(pipeline));
76
    }
77
78
    @Inject(
79
            method = "setPipeline",
80
            at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vulkan/VulkanDevice;getOrCompilePipeline(Lcom/mojang/blaze3d/pipeline/RenderPipeline;)Lcom/mojang/blaze3d/vulkan/VulkanRenderPipeline;", shift = At.Shift.AFTER)
81
    )
82
    private void combatant$compilePipelineAfter(RenderPipeline pipeline, CallbackInfo ci) {
83
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pipeline.get.after", "pipeline", pipelineId(pipeline));
84
    }
85
86
    @Inject(
87
            method = "setPipeline",
88
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdBindPipeline(Lorg/lwjgl/vulkan/VkCommandBuffer;IJ)V", shift = At.Shift.BEFORE)
89
    )
90
    private void combatant$bindPipelineBefore(RenderPipeline pipeline, CallbackInfo ci) {
91
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.bindpipeline.before", "pipeline", pipelineId(pipeline));
92
    }
93
94
    @Inject(
95
            method = "setPipeline",
96
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdBindPipeline(Lorg/lwjgl/vulkan/VkCommandBuffer;IJ)V", shift = At.Shift.AFTER)
97
    )
98
    private void combatant$bindPipelineAfter(RenderPipeline pipeline, CallbackInfo ci) {
99
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.bindpipeline.after", "pipeline", pipelineId(pipeline));
100
    }
101
102
    @Inject(method = "setPipeline", at = @At("TAIL"))
103
    private void combatant$setPipelineTail(RenderPipeline pipeline, CallbackInfo ci) {
104
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.setpipeline.tail", "pipeline", pipelineId(pipeline));
105
    }
106
107
    @Inject(method = "bindTexture", at = @At("HEAD"))
108
    private void combatant$bindTextureHead(String name, GpuTextureView view, GpuSampler sampler, CallbackInfo ci) {
109
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.bindtexture.head", "name", name, "view", objectText(view), "sampler", objectText(sampler));
110
    }
111
112
    @Inject(method = "setUniform(Ljava/lang/String;Lcom/mojang/blaze3d/buffers/GpuBufferSlice;)V", at = @At("HEAD"))
113
    private void combatant$setUniformSliceHead(String name, GpuBufferSlice slice, CallbackInfo ci) {
114
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.uniform.slice.head", "name", name, "slice", sliceText(slice));
115
    }
116
117
    @Inject(method = "setUniform(Ljava/lang/String;Lcom/mojang/blaze3d/buffers/GpuBuffer;)V", at = @At("HEAD"))
118
    private void combatant$setUniformBufferHead(String name, GpuBuffer buffer, CallbackInfo ci) {
119
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.uniform.buffer.head", "name", name, "buffer", bufferText(buffer));
120
    }
121
122
    @Inject(method = "enableScissor", at = @At("HEAD"))
123
    private void combatant$enableScissorHead(int x, int y, int width, int height, CallbackInfo ci) {
124
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.scissor.enable.head", "rect", x + "," + y + " " + width + "x" + height);
125
    }
126
127
    @Inject(method = "setVertexBuffer", at = @At("HEAD"))
128
    private void combatant$vertexBufferHead(int slot, GpuBufferSlice slice, CallbackInfo ci) {
129
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.vertexbuffer.head", "slot", slot, "slice", sliceText(slice));
130
    }
131
132
    @Inject(method = "setIndexBuffer", at = @At("HEAD"))
133
    private void combatant$indexBufferHead(GpuBuffer buffer, IndexType indexType, CallbackInfo ci) {
134
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.indexbuffer.head", "buffer", bufferText(buffer), "type", indexType);
135
    }
136
137
    @Inject(method = "pushDescriptors", at = @At("HEAD"))
138
    private void combatant$pushDescriptorsHead(CallbackInfo ci) {
139
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pushdescriptors.head");
140
    }
141
142
    @Inject(
143
            method = "pushDescriptors",
144
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRPushDescriptor;vkCmdPushDescriptorSetKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;IJILorg/lwjgl/vulkan/VkWriteDescriptorSet$Buffer;)V", shift = At.Shift.BEFORE)
145
    )
146
    private void combatant$pushDescriptorsNativeBefore(CallbackInfo ci) {
147
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pushdescriptors.native.before");
148
    }
149
150
    @Inject(
151
            method = "pushDescriptors",
152
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/KHRPushDescriptor;vkCmdPushDescriptorSetKHR(Lorg/lwjgl/vulkan/VkCommandBuffer;IJILorg/lwjgl/vulkan/VkWriteDescriptorSet$Buffer;)V", shift = At.Shift.AFTER)
153
    )
154
    private void combatant$pushDescriptorsNativeAfter(CallbackInfo ci) {
155
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pushdescriptors.native.after");
156
    }
157
158
    @Inject(method = "pushDescriptors", at = @At("TAIL"))
159
    private void combatant$pushDescriptorsTail(CallbackInfo ci) {
160
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.pushdescriptors.tail");
161
    }
162
163
    @Inject(method = "drawIndexed", at = @At("HEAD"))
164
    private void combatant$drawIndexedHead(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance, CallbackInfo ci) {
165
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.drawindexed.head",
166
                "indices", indexCount,
167
                "instances", instanceCount,
168
                "firstIndex", firstIndex,
169
                "vertexOffset", vertexOffset,
170
                "firstInstance", firstInstance);
171
    }
172
173
    @Inject(
174
            method = "drawIndexed",
175
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdDrawIndexed(Lorg/lwjgl/vulkan/VkCommandBuffer;IIIII)V", shift = At.Shift.BEFORE)
176
    )
177
    private void combatant$drawIndexedNativeBefore(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance, CallbackInfo ci) {
178
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.drawindexed.native.before", "indices", indexCount);
179
    }
180
181
    @Inject(
182
            method = "drawIndexed",
183
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdDrawIndexed(Lorg/lwjgl/vulkan/VkCommandBuffer;IIIII)V", shift = At.Shift.AFTER)
184
    )
185
    private void combatant$drawIndexedNativeAfter(int indexCount, int instanceCount, int firstIndex, int vertexOffset, int firstInstance, CallbackInfo ci) {
186
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.drawindexed.native.after", "indices", indexCount);
187
    }
188
189
    @Inject(method = "draw", at = @At("HEAD"))
190
    private void combatant$drawHead(int vertexCount, int instanceCount, int firstVertex, int firstInstance, CallbackInfo ci) {
191
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.draw.head",
192
                "vertices", vertexCount,
193
                "instances", instanceCount,
194
                "firstVertex", firstVertex,
195
                "firstInstance", firstInstance);
196
    }
197
198
    @Inject(
199
            method = "draw",
200
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdDraw(Lorg/lwjgl/vulkan/VkCommandBuffer;IIII)V", shift = At.Shift.BEFORE)
201
    )
202
    private void combatant$drawNativeBefore(int vertexCount, int instanceCount, int firstVertex, int firstInstance, CallbackInfo ci) {
203
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.draw.native.before", "vertices", vertexCount);
204
    }
205
206
    @Inject(
207
            method = "draw",
208
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCmdDraw(Lorg/lwjgl/vulkan/VkCommandBuffer;IIII)V", shift = At.Shift.AFTER)
209
    )
210
    private void combatant$drawNativeAfter(int vertexCount, int instanceCount, int firstVertex, int firstInstance, CallbackInfo ci) {
211
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.draw.native.after", "vertices", vertexCount);
212
    }
213
214
    @Inject(method = "multiDraw(Ljava/nio/IntBuffer;III)V", at = @At("HEAD"))
215
    private void combatant$multiDrawHead(IntBuffer buffer, int firstInstance, int drawCount, int stride, CallbackInfo ci) {
216
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.multidraw.head", "draws", drawCount, "stride", stride, "remaining", buffer == null ? -1 : buffer.remaining());
217
    }
218
219
    @Inject(method = "multiDrawIndexed(Ljava/nio/IntBuffer;III)V", at = @At("HEAD"))
220
    private void combatant$multiDrawIndexedHead(IntBuffer buffer, int firstInstance, int drawCount, int stride, CallbackInfo ci) {
221
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.multidrawindexed.head", "draws", drawCount, "stride", stride, "remaining", buffer == null ? -1 : buffer.remaining());
222
    }
223
224
    @Inject(method = "multiDrawIndexed(Lorg/lwjgl/PointerBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;I)V", at = @At("HEAD"))
225
    private void combatant$multiDrawIndexedPointerHead(PointerBuffer firstIndex, IntBuffer indexCount, IntBuffer baseVertex, int drawCount, CallbackInfo ci) {
226
        VulkanCrashDiagnostics.breadcrumbDraw("renderpass.multidrawindexed.pointer.head", "draws", drawCount);
227
    }
228
229
    @Inject(method = "drawMultipleIndexed", at = @At("HEAD"))
230
    private <T> void combatant$drawMultipleIndexedHead(Collection<RenderPass.Draw<T>> draws,
231
                                                       GpuBuffer indexBuffer,
232
                                                       IndexType indexType,
233
                                                       Collection<String> dynamicUniforms,
234
                                                       T extraData,
235
                                                       CallbackInfo ci) {
236
        VulkanCrashDiagnostics.breadcrumbQuiet("renderpass.drawmultipleindexed.head",
237
                "draws", draws == null ? -1 : draws.size(),
238
                "indexBuffer", bufferText(indexBuffer),
239
                "indexType", indexType,
240
                "dynamicUniforms", dynamicUniforms == null ? -1 : dynamicUniforms.size());
241
    }
242
243
    private static String pipelineId(RenderPipeline pipeline) {
244
        if (pipeline == null) return "<null>";
245
        try {
246
            return String.valueOf(pipeline.getLocation());
247
        } catch (Throwable ignored) {
248
            return pipeline.toString();
249
        }
250
    }
251
252
    private static String labelText(Supplier<String> label) {
253
        if (label == null) return "<null>";
254
        try {
255
            String value = label.get();
256
            return value == null ? "<null>" : value;
257
        } catch (Throwable t) {
258
            return "<label-error:" + t.getClass().getSimpleName() + ">";
259
        }
260
    }
261
262
    private static String areaText(RenderPass.RenderArea area) {
263
        if (area == null) return "<null>";
264
        return area.x() + "," + area.y() + " " + area.width() + "x" + area.height();
265
    }
266
267
    private static String sliceText(GpuBufferSlice slice) {
268
        if (slice == null) return "<null>";
269
        try {
270
            return "offset=" + slice.offset() + " buffer=" + bufferText(slice.buffer());
271
        } catch (Throwable t) {
272
            return "<slice-error:" + t.getClass().getSimpleName() + ">";
273
        }
274
    }
275
276
    private static String bufferText(GpuBuffer buffer) {
277
        if (buffer == null) return "<null>";
278
        try {
279
            return buffer.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(buffer)) + " closed=" + buffer.isClosed();
280
        } catch (Throwable t) {
281
            return buffer.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(buffer)) + " error=" + t.getClass().getSimpleName();
282
        }
283
    }
284
285
    private static String objectText(Object object) {
286
        if (object == null) return "<null>";
287
        return object.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(object));
288
    }
289
}
290
VulkanRenderPipelineDiagnosticsMixinsrc/vulkanDebug/java/combatant/client/mixins/VulkanRenderPipelineDiagnosticsMixin.javaJava · 38 lines · 2.3 KB
@Mixin(VulkanRenderPipeline.class)
VulkanRenderPipelineDiagnosticsMixin.javaJava · 38 lines · 2.3 KB · complete file, verbatimOriginal ↗
1
package combatant.client.mixins;
2
3
import com.llamalad7.mixinextras.sugar.Local;
4
import com.mojang.blaze3d.pipeline.RenderPipeline;
5
import com.mojang.blaze3d.vulkan.VulkanBindGroupLayout;
6
import com.mojang.blaze3d.vulkan.VulkanDevice;
7
import com.mojang.blaze3d.vulkan.VulkanRenderPipeline;
8
import org.lwjgl.vulkan.VkPipelineDepthStencilStateCreateInfo;
9
import org.lwjgl.vulkan.VkPipelineRenderingCreateInfoKHR;
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.injection.At;
12
import org.spongepowered.asm.mixin.injection.Inject;
13
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14
import combatant.client.render.engine.rhi.backend.vulkan.debug.VulkanCrashDiagnostics;
15
import combatant.client.render.engine.rhi.backend.vulkan.util.VulkanRenderStateBridge;
16
17
@Mixin(VulkanRenderPipeline.class)
18
public abstract class VulkanRenderPipelineDiagnosticsMixin {
19
    @Inject(
20
            method = "compile",
21
            at = @At(value = "INVOKE", target = "Lorg/lwjgl/vulkan/VK12;vkCreateGraphicsPipelines(Lorg/lwjgl/vulkan/VkDevice;JLorg/lwjgl/vulkan/VkGraphicsPipelineCreateInfo$Buffer;Lorg/lwjgl/vulkan/VkAllocationCallbacks;Ljava/nio/LongBuffer;)I", ordinal = 0, shift = At.Shift.BEFORE)
22
    )
23
    private static void combatant$logPipelineCompile(VulkanDevice device,
24
                                                     VulkanBindGroupLayout layout,
25
                                                     RenderPipeline pipeline,
26
                                                     long vertexModule,
27
                                                     long fragmentModule,
28
                                                     CallbackInfoReturnable<VulkanRenderPipeline> cir,
29
                                                     @Local VkPipelineRenderingCreateInfoKHR rendering,
30
                                                     @Local VkPipelineDepthStencilStateCreateInfo depthStencil) {
31
        VulkanCrashDiagnostics.breadcrumbQuiet("pipeline.compile.before",
32
                "pipeline", pipeline == null || pipeline.getLocation() == null ? "<unknown>" : pipeline.getLocation(),
33
                "samples", VulkanRenderStateBridge.currentVkSampleCount(),
34
                "stencil", VulkanRenderStateBridge.pipelineNeedsStencilFormat(pipeline),
35
                "stencilMode", VulkanRenderStateBridge.stencilMode());
36
    }
37
}
38