OfflineClient

OfflineClient modules for Minecraft 26.2: 209 modules across 6 categories, each with its complete source file.

Minecraft 26.2209 modulesJava103 mixins

Mixins (103)

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

AbstractClientPlayerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/AbstractClientPlayerMixin.javaJava · 25 lines · 1.1 KB
@Mixin(AbstractClientPlayer.class)
AbstractClientPlayerMixin.javaJava · 25 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.NameProtect;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.player.AbstractClientPlayer;
6
import net.minecraft.client.resources.DefaultPlayerSkin;
7
import net.minecraft.world.entity.player.PlayerSkin;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
// NameProtect can hand every player the default skin. Nobody is recognised on a stream.
14
@Mixin(AbstractClientPlayer.class)
15
public abstract class AbstractClientPlayerMixin {
16
17
    @Inject(method = "getSkin", at = @At("HEAD"), cancellable = true)
18
    private void onGetSkin(CallbackInfoReturnable<PlayerSkin> cir) {
19
        NameProtect nameProtect = Modules.active(NameProtect.class);
20
        if (nameProtect != null && nameProtect.hidesSkins()) {
21
            cir.setReturnValue(DefaultPlayerSkin.get(((AbstractClientPlayer) (Object) this).getUUID()));
22
        }
23
    }
24
}
25
AbstractContainerScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/AbstractContainerScreenMixin.javaJava · 123 lines · 5.2 KB
@Mixin(AbstractContainerScreen.class)
AbstractContainerScreenMixin.javaJava · 123 lines · 5.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.player.ChestStealer;
5
import com.jellypudding.offlineclient.modules.player.InventoryTweaks;
6
import com.jellypudding.offlineclient.modules.render.BetterTooltips;
7
import com.jellypudding.offlineclient.modules.render.ItemHighlight;
8
import com.jellypudding.offlineclient.util.Modules;
9
import net.minecraft.client.gui.GuiGraphicsExtractor;
10
import net.minecraft.client.gui.components.Button;
11
import net.minecraft.client.gui.screens.Screen;
12
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
13
import net.minecraft.client.input.KeyEvent;
14
import net.minecraft.client.input.MouseButtonEvent;
15
import net.minecraft.world.inventory.AbstractContainerMenu;
16
import net.minecraft.world.inventory.ContainerInput;
17
import net.minecraft.world.inventory.Slot;
18
import net.minecraft.network.chat.Component;
19
import org.lwjgl.glfw.GLFW;
20
import org.spongepowered.asm.mixin.Mixin;
21
import org.spongepowered.asm.mixin.Shadow;
22
import org.spongepowered.asm.mixin.injection.At;
23
import org.spongepowered.asm.mixin.injection.Inject;
24
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
26
27
@Mixin(AbstractContainerScreen.class)
28
public abstract class AbstractContainerScreenMixin extends Screen {
29
30
    private static final int BUTTON_WIDTH = 40;
31
    private static final int BUTTON_HEIGHT = 14;
32
33
    private AbstractContainerScreenMixin(Component title) {
34
        super(title);
35
    }
36
37
    @Shadow
38
    protected Slot hoveredSlot;
39
40
    @Shadow
41
    protected int leftPos;
42
43
    @Shadow
44
    protected int topPos;
45
46
    @Shadow
47
    public abstract AbstractContainerMenu getMenu();
48
49
    // Two buttons above the container that run one pass on click.
50
    @Inject(method = "init", at = @At("TAIL"))
51
    private void onInit(CallbackInfo ci) {
52
        ChestStealer stealer = Modules.get(ChestStealer.class);
53
        if (stealer == null || !stealer.showsButtons()
54
            || !stealer.handles((Screen) (Object) this)) {
55
            return;
56
        }
57
        int y = topPos - BUTTON_HEIGHT - 2;
58
        addRenderableWidget(Button.builder(Component.literal("Steal"),
59
                button -> stealer.stealNow())
60
            .bounds(leftPos, y, BUTTON_WIDTH, BUTTON_HEIGHT).build());
61
        addRenderableWidget(Button.builder(Component.literal("Dump"),
62
                button -> stealer.dumpNow())
63
            .bounds(leftPos + BUTTON_WIDTH + 2, y, BUTTON_WIDTH, BUTTON_HEIGHT).build());
64
    }
65
66
    // The paint goes down before the item and sits under it.
67
    @Inject(method = "extractSlot", at = @At("HEAD"))
68
    private void onExtractSlot(GuiGraphicsExtractor graphics, Slot slot, int mouseX, int mouseY,
69
                               CallbackInfo ci) {
70
        ItemHighlight highlight = Modules.get(ItemHighlight.class);
71
        if (highlight == null) {
72
            return;
73
        }
74
        int color = highlight.colorFor(slot.getItem());
75
        if (color != 0) {
76
            graphics.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, color);
77
        }
78
    }
79
80
    @Inject(method = "mouseClicked(Lnet/minecraft/client/input/MouseButtonEvent;Z)Z",
81
        at = @At("HEAD"), cancellable = true)
82
    private void onMouseClicked(MouseButtonEvent event, boolean doubleClick, CallbackInfoReturnable<Boolean> cir) {
83
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
84
        if (tooltips != null && tooltips.wantsToOpen(event) && openHovered(tooltips)) {
85
            cir.setReturnValue(true);
86
        }
87
    }
88
89
    @Inject(method = "keyPressed(Lnet/minecraft/client/input/KeyEvent;)Z",
90
        at = @At("HEAD"), cancellable = true)
91
    private void onKeyPressed(KeyEvent event, CallbackInfoReturnable<Boolean> cir) {
92
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
93
        if (tooltips != null && tooltips.wantsToOpen(event) && openHovered(tooltips)) {
94
            cir.setReturnValue(true);
95
        }
96
    }
97
98
    // Shift and a held left button move every stack the cursor is dragged over.
99
    @Inject(method = "mouseDragged(Lnet/minecraft/client/input/MouseButtonEvent;DD)Z",
100
        at = @At("HEAD"))
101
    private void onMouseDragged(MouseButtonEvent event, double dragX, double dragY,
102
                                CallbackInfoReturnable<Boolean> cir) {
103
        InventoryTweaks tweaks = Modules.get(InventoryTweaks.class);
104
        if (tweaks == null || !tweaks.dragsStacks()
105
            || event.button() != GLFW.GLFW_MOUSE_BUTTON_LEFT || !event.hasShiftDown()) {
106
            return;
107
        }
108
        if (hoveredSlot == null || !hoveredSlot.hasItem() || !getMenu().getCarried().isEmpty()) {
109
            return;
110
        }
111
        OfflineClient.MC.gameMode.handleContainerInput(getMenu().containerId, hoveredSlot.index, 0,
112
            ContainerInput.QUICK_MOVE, OfflineClient.MC.player);
113
    }
114
115
    // Nothing opens whilst an item is on the cursor. A drop still lands.
116
    private boolean openHovered(BetterTooltips tooltips) {
117
        if (hoveredSlot == null || hoveredSlot.getItem().isEmpty() || !getMenu().getCarried().isEmpty()) {
118
            return false;
119
        }
120
        return tooltips.openContents(hoveredSlot.getItem());
121
    }
122
}
123
AbstractSignRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/AbstractSignRendererMixin.javaJava · 23 lines · 889 B
@Mixin(AbstractSignRenderer.class)
AbstractSignRendererMixin.javaJava · 23 lines · 889 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.blockentity.AbstractSignRenderer;
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.CallbackInfo;
10
11
@Mixin(AbstractSignRenderer.class)
12
public abstract class AbstractSignRendererMixin {
13
14
    // The board is still drawn. Only the lines on it are skipped.
15
    @Inject(method = "submitSignText", at = @At("HEAD"), cancellable = true)
16
    private void onSubmitSignText(CallbackInfo ci) {
17
        NoRender noRender = Modules.get(NoRender.class);
18
        if (noRender != null && noRender.hidesSignText()) {
19
            ci.cancel();
20
        }
21
    }
22
}
23
AttackRangeMixinsrc/main/java/com/jellypudding/offlineclient/mixin/AttackRangeMixin.javaJava · 38 lines · 1.5 KB
@Mixin(AttackRange.class)
ModifiesAttackRange
AttackRangeMixin.javaJava · 38 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.combat.Hitboxes;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.item.component.AttackRange;
6
import org.objectweb.asm.Opcodes;
7
import org.spongepowered.asm.mixin.Final;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.Shadow;
10
import org.spongepowered.asm.mixin.injection.At;
11
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
12
import org.spongepowered.asm.mixin.injection.Redirect;
13
14
@Mixin(AttackRange.class)
15
public abstract class AttackRangeMixin {
16
17
    @Shadow
18
    @Final
19
    private float hitboxMargin;
20
21
    @Redirect(method = "isInRange(Lnet/minecraft/world/entity/LivingEntity;Ljava/util/function/ToDoubleFunction;D)Z",
22
        at = @At(value = "FIELD",
23
            target = "Lnet/minecraft/world/item/component/AttackRange;hitboxMargin:F",
24
            opcode = Opcodes.GETFIELD))
25
    private float growMargin(AttackRange self) {
26
        Hitboxes hitboxes = Modules.get(Hitboxes.class);
27
        return hitboxes == null ? hitboxMargin : hitboxMargin + hitboxes.margin();
28
    }
29
30
    // The crosshair pick inflates every entity box using this accessor.
31
    // Growing it here lands hits since the server allows three blocks of slack.
32
    @ModifyReturnValue(method = "hitboxMargin()F", at = @At("RETURN"))
33
    private float onHitboxMargin(float original) {
34
        Hitboxes hitboxes = Modules.get(Hitboxes.class);
35
        return hitboxes == null ? original : original + hitboxes.margin();
36
    }
37
}
38
AvatarRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/AvatarRendererMixin.javaJava · 50 lines · 2.9 KB
@Mixin(AvatarRenderer.class)
AvatarRendererMixin.javaJava · 50 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Chams;
4
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
5
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
6
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
7
import com.mojang.blaze3d.vertex.PoseStack;
8
import net.minecraft.client.model.geom.ModelPart;
9
import net.minecraft.client.renderer.SubmitNodeCollector;
10
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
11
import net.minecraft.client.renderer.rendertype.RenderType;
12
import net.minecraft.client.renderer.rendertype.RenderTypes;
13
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
14
import net.minecraft.resources.Identifier;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.injection.At;
17
18
// Chams paints your first person arm.
19
@Mixin(AvatarRenderer.class)
20
public abstract class AvatarRendererMixin {
21
22
    @ModifyExpressionValue(
23
        method = "renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;Lnet/minecraft/client/model/geom/ModelPart;Z)V",
24
        at = @At(value = "INVOKE",
25
            target = "Lnet/minecraft/client/renderer/rendertype/RenderTypes;entityTranslucent(Lnet/minecraft/resources/Identifier;)Lnet/minecraft/client/renderer/rendertype/RenderType;"))
26
    private RenderType onHandType(RenderType original, PoseStack poseStack, SubmitNodeCollector collector,
27
                                  int light, Identifier skin, ModelPart arm, boolean sleeve) {
28
        Chams chams = Chams.get();
29
        if (chams == null || !chams.paintsHand()) {
30
            return original;
31
        }
32
        return RenderTypes.entityTranslucent(chams.handTexture(skin));
33
    }
34
35
    @WrapOperation(
36
        method = "renderHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;ILnet/minecraft/resources/Identifier;Lnet/minecraft/client/model/geom/ModelPart;Z)V",
37
        at = @At(value = "INVOKE",
38
            target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModelPart(Lnet/minecraft/client/model/geom/ModelPart;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;IILnet/minecraft/client/renderer/texture/TextureAtlasSprite;)V"))
39
    private void onSubmitHand(SubmitNodeCollector collector, ModelPart part, PoseStack poseStack,
40
                              RenderType type, int light, int overlay, TextureAtlasSprite sprite,
41
                              Operation<Void> original) {
42
        Chams chams = Chams.get();
43
        if (chams == null || !chams.paintsHand()) {
44
            original.call(collector, part, poseStack, type, light, overlay, sprite);
45
            return;
46
        }
47
        collector.submitModelPart(part, poseStack, type, light, overlay, sprite, chams.handColor(), null);
48
    }
49
}
50
BannerRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BannerRendererMixin.javaJava · 64 lines · 2.6 KB
@Mixin(BannerRenderer.class)
BannerRendererMixin.javaJava · 64 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
6
import com.mojang.blaze3d.vertex.PoseStack;
7
import net.minecraft.client.model.object.banner.BannerModel;
8
import net.minecraft.client.renderer.Sheets;
9
import net.minecraft.client.renderer.SubmitNodeCollector;
10
import net.minecraft.client.renderer.blockentity.BannerRenderer;
11
import net.minecraft.client.renderer.blockentity.state.BannerRenderState;
12
import net.minecraft.client.renderer.state.level.CameraRenderState;
13
import net.minecraft.client.renderer.texture.OverlayTexture;
14
import net.minecraft.client.resources.model.sprite.SpriteGetter;
15
import net.minecraft.util.Unit;
16
import net.minecraft.world.level.block.BannerBlock;
17
import org.spongepowered.asm.mixin.Final;
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 org.spongepowered.asm.mixin.injection.Inject;
23
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
24
25
@Mixin(BannerRenderer.class)
26
public abstract class BannerRendererMixin {
27
28
    @Unique
29
    private static final String SUBMIT = "submit(Lnet/minecraft/client/renderer/blockentity/state/BannerRenderState;"
30
        + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;"
31
        + "Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V";
32
33
    @Shadow
34
    @Final
35
    private SpriteGetter sprites;
36
37
    @Shadow
38
    protected abstract BannerModel bannerModel(BannerBlock.AttachmentType type);
39
40
    @Inject(method = SUBMIT, at = @At("HEAD"), cancellable = true)
41
    private void onSubmit(BannerRenderState state, PoseStack poseStack, SubmitNodeCollector collector,
42
                          CameraRenderState camera, CallbackInfo ci) {
43
        NoRender noRender = Modules.get(NoRender.class);
44
        if (noRender == null) {
45
            return;
46
        }
47
        switch (noRender.bannerMode()) {
48
            case HIDE -> ci.cancel();
49
            case POLE_ONLY -> {
50
                // The pole model is the bar and post without the cloth.
51
                poseStack.pushPose();
52
                poseStack.mulPose(state.transformation);
53
                collector.submitModel(bannerModel(state.attachmentType), Unit.INSTANCE, poseStack,
54
                    state.lightCoords, OverlayTexture.NO_OVERLAY, -1, Sheets.BANNER_BASE, sprites,
55
                    0, state.breakProgress);
56
                poseStack.popPose();
57
                ci.cancel();
58
            }
59
            case SHOW -> {
60
            }
61
        }
62
    }
63
}
64
BeaconRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BeaconRendererMixin.javaJava · 30 lines · 1.5 KB
@Mixin(BeaconRenderer.class)
BeaconRendererMixin.javaJava · 30 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.renderer.SubmitNodeCollector;
7
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
8
import net.minecraft.client.renderer.blockentity.state.BeaconRenderState;
9
import net.minecraft.client.renderer.state.level.CameraRenderState;
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
15
@Mixin(BeaconRenderer.class)
16
public abstract class BeaconRendererMixin {
17
18
    // The beam is all this renderer draws. The block itself is part of the chunk.
19
    @Inject(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",
20
        at = @At("HEAD"), cancellable = true)
21
    private void onSubmit(BeaconRenderState state, PoseStack poseStack,
22
                          SubmitNodeCollector collector, CameraRenderState camera,
23
                          CallbackInfo ci) {
24
        NoRender noRender = Modules.get(NoRender.class);
25
        if (noRender != null && noRender.hidesBeaconBeams()) {
26
            ci.cancel();
27
        }
28
    }
29
}
30
BeaconScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BeaconScreenMixin.javaJava · 73 lines · 3.0 KB
@Mixin(BeaconScreen.class)
ModifiesBeaconScreen
BeaconScreenMixin.javaJava · 73 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterBeacons;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.gui.components.AbstractWidget;
6
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
7
import net.minecraft.client.gui.screens.inventory.BeaconScreen;
8
import net.minecraft.network.chat.Component;
9
import net.minecraft.world.entity.player.Inventory;
10
import net.minecraft.world.inventory.BeaconMenu;
11
import net.minecraft.core.Holder;
12
import net.minecraft.world.effect.MobEffect;
13
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
14
import org.spongepowered.asm.mixin.Mixin;
15
import org.spongepowered.asm.mixin.Shadow;
16
import org.spongepowered.asm.mixin.Unique;
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
import java.util.ArrayList;
22
import java.util.List;
23
24
// Every effect is offered whatever the pyramid is worth. A tier of nought keeps
25
// a button live and a tier of three greys it out below a full pyramid.
26
@Mixin(BeaconScreen.class)
27
public abstract class BeaconScreenMixin extends AbstractContainerScreen<BeaconMenu> {
28
29
    private static final int BUTTON_SIZE = 24;
30
    private static final int COLUMNS = 3;
31
    private static final int PRIMARY_TIER = 0;
32
    private static final int SECONDARY_TIER = 3;
33
34
    private BeaconScreenMixin(BeaconMenu menu, Inventory inventory, Component title) {
35
        super(menu, inventory, title);
36
    }
37
38
    @Shadow
39
    private void addBeaconButton(AbstractWidget button) {
40
    }
41
42
    @Inject(method = "init",
43
        at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", shift = At.Shift.AFTER),
44
        cancellable = true)
45
    private void onInit(CallbackInfo ci) {
46
        if (!Modules.enabled(BetterBeacons.class)) {
47
            return;
48
        }
49
        List<Holder<MobEffect>> effects = new ArrayList<>();
50
        for (List<Holder<MobEffect>> tier : BeaconBlockEntity.BEACON_EFFECTS) {
51
            effects.addAll(tier);
52
        }
53
        offlineclient$grid(effects, leftPos + 20, topPos + 22, true, PRIMARY_TIER);
54
        offlineclient$grid(effects, leftPos + 116, topPos + 22, false, SECONDARY_TIER);
55
        BeaconScreen screen = (BeaconScreen) (Object) this;
56
        addBeaconButton(screen.new BeaconConfirmButton(leftPos + 164, topPos + 107));
57
        addBeaconButton(screen.new BeaconCancelButton(leftPos + 190, topPos + 107));
58
        ci.cancel();
59
    }
60
61
    @Unique
62
    private void offlineclient$grid(List<Holder<MobEffect>> effects, int x, int y,
63
                                    boolean primary, int tier) {
64
        for (int i = 0; i < effects.size(); i++) {
65
            int column = i % COLUMNS;
66
            int row = i / COLUMNS;
67
            BeaconScreen screen = (BeaconScreen) (Object) this;
68
            addBeaconButton(screen.new BeaconPowerButton(x + column * BUTTON_SIZE,
69
                y + row * BUTTON_SIZE, effects.get(i), primary, tier));
70
        }
71
    }
72
}
73
BiomeColorsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BiomeColorsMixin.javaJava · 44 lines · 1.9 KB
@Mixin(BiomeColors.class)
ModifiesBiomeColors
BiomeColorsMixin.javaJava · 44 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.BiomeColors;
6
import net.minecraft.client.renderer.block.BlockAndTintGetter;
7
import net.minecraft.core.BlockPos;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
// The tints a chunk build bakes into grass and leaves and water.
14
@Mixin(BiomeColors.class)
15
public abstract class BiomeColorsMixin {
16
17
    @Inject(method = "getAverageGrassColor", at = @At("HEAD"), cancellable = true)
18
    private static void onGrassColor(BlockAndTintGetter level, BlockPos pos,
19
                                     CallbackInfoReturnable<Integer> cir) {
20
        Ambience ambience = Modules.get(Ambience.class);
21
        if (ambience != null && ambience.paintsGrass()) {
22
            cir.setReturnValue(ambience.grassColor());
23
        }
24
    }
25
26
    @Inject(method = "getAverageFoliageColor", at = @At("HEAD"), cancellable = true)
27
    private static void onFoliageColor(BlockAndTintGetter level, BlockPos pos,
28
                                       CallbackInfoReturnable<Integer> cir) {
29
        Ambience ambience = Modules.get(Ambience.class);
30
        if (ambience != null && ambience.paintsFoliage()) {
31
            cir.setReturnValue(ambience.foliageColor());
32
        }
33
    }
34
35
    @Inject(method = "getAverageWaterColor", at = @At("HEAD"), cancellable = true)
36
    private static void onWaterColor(BlockAndTintGetter level, BlockPos pos,
37
                                     CallbackInfoReturnable<Integer> cir) {
38
        Ambience ambience = Modules.get(Ambience.class);
39
        if (ambience != null && ambience.paintsWater()) {
40
            cir.setReturnValue(ambience.waterColor());
41
        }
42
    }
43
}
44
BlockCollisionsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BlockCollisionsMixin.javaJava · 59 lines · 2.9 KB
@Mixin(BlockCollisions.class)
BlockCollisionsMixin.javaJava · 59 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.player.AntiCactus;
5
import com.jellypudding.offlineclient.modules.movement.Jesus;
6
import com.jellypudding.offlineclient.modules.world.Collisions;
7
import com.jellypudding.offlineclient.util.Modules;
8
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
9
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
10
import net.minecraft.client.player.LocalPlayer;
11
import net.minecraft.core.BlockPos;
12
import net.minecraft.world.entity.Entity;
13
import net.minecraft.world.level.BlockCollisions;
14
import net.minecraft.world.level.CollisionGetter;
15
import net.minecraft.world.level.block.Blocks;
16
import net.minecraft.world.level.block.state.BlockState;
17
import net.minecraft.world.phys.shapes.Shapes;
18
import net.minecraft.world.phys.shapes.CollisionContext;
19
import net.minecraft.world.phys.shapes.EntityCollisionContext;
20
import net.minecraft.world.phys.shapes.VoxelShape;
21
import org.spongepowered.asm.mixin.Mixin;
22
import org.spongepowered.asm.mixin.injection.At;
23
24
// Every block shape the player can bump into passes through here.
25
@Mixin(BlockCollisions.class)
26
public abstract class BlockCollisionsMixin {
27
28
    @WrapOperation(method = "computeNext()Ljava/lang/Object;",
29
        at = @At(value = "INVOKE",
30
            target = "Lnet/minecraft/world/phys/shapes/CollisionContext;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/shapes/VoxelShape;"))
31
    private VoxelShape wrapCollisionShape(CollisionContext context, BlockState state,
32
                                          CollisionGetter getter, BlockPos pos,
33
                                          Operation<VoxelShape> original) {
34
        VoxelShape shape = original.call(context, state, getter, pos);
35
        LocalPlayer player = OfflineClient.MC.player;
36
        if (!(context instanceof EntityCollisionContext entityContext)
37
            || entityContext.getEntity() == null || player == null) {
38
            return shape;
39
        }
40
        Entity entity = entityContext.getEntity();
41
        // The ridden vehicle collides on the player's behalf whilst Jesus carries it.
42
        if (entity != player && entity != player.getVehicle()) {
43
            return shape;
44
        }
45
        if (entity == player && state.is(Blocks.CACTUS) && Modules.enabled(AntiCactus.class)) {
46
            return Shapes.block();
47
        }
48
        Collisions collisions = Modules.active(Collisions.class);
49
        if (collisions != null) {
50
            VoxelShape forced = collisions.forcedShape(state, pos);
51
            if (forced != null) {
52
                return forced;
53
            }
54
        }
55
        Jesus jesus = Modules.get(Jesus.class);
56
        return jesus == null ? shape : jesus.adjustShape(entity, state, pos, shape);
57
    }
58
}
59
BlockEntityRenderDispatcherMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BlockEntityRenderDispatcherMixin.javaJava · 57 lines · 3.0 KB
@Mixin(BlockEntityRenderDispatcher.class)
BlockEntityRenderDispatcherMixin.javaJava · 57 lines · 3.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.render.ChestEsp;
5
import com.jellypudding.offlineclient.modules.render.NoRender;
6
import com.jellypudding.offlineclient.modules.render.XRay;
7
import com.jellypudding.offlineclient.util.Modules;
8
import com.mojang.blaze3d.vertex.PoseStack;
9
import net.minecraft.client.renderer.SubmitNodeCollector;
10
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
11
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
12
import net.minecraft.client.renderer.state.level.CameraRenderState;
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
18
@Mixin(BlockEntityRenderDispatcher.class)
19
public abstract class BlockEntityRenderDispatcherMixin {
20
21
    // Chests and other block entities vanish with the block XRay hides.
22
    @Inject(
23
        method = "submit(Lnet/minecraft/client/renderer/blockentity/state/BlockEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
24
        at = @At("HEAD"),
25
        cancellable = true)
26
    private <S extends BlockEntityRenderState> void onSubmit(S state, PoseStack poseStack,
27
                                                              SubmitNodeCollector collector,
28
                                                              CameraRenderState camera, CallbackInfo ci) {
29
        if (state.blockPos == null || OfflineClient.MC.level == null) {
30
            return;
31
        }
32
        NoRender noRender = Modules.get(NoRender.class);
33
        if (noRender != null && noRender.hidesBlockEntity(
34
            OfflineClient.MC.level.getBlockState(state.blockPos).getBlock())) {
35
            ci.cancel();
36
            return;
37
        }
38
        if (XRay.meshAlphaFor(OfflineClient.MC.level,
39
            OfflineClient.MC.level.getBlockState(state.blockPos), state.blockPos) == 0) {
40
            ci.cancel();
41
            return;
42
        }
43
        ChestEsp chestEsp = Modules.get(ChestEsp.class);
44
        ChestEsp.setCurrentGlow(chestEsp == null ? 0 : chestEsp.glowFor(state.blockPos));
45
    }
46
47
    // The glow colour only lasts for the one submit it was set for.
48
    @Inject(
49
        method = "submit(Lnet/minecraft/client/renderer/blockentity/state/BlockEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
50
        at = @At("RETURN"))
51
    private <S extends BlockEntityRenderState> void onSubmitEnd(S state, PoseStack poseStack,
52
                                                                 SubmitNodeCollector collector,
53
                                                                 CameraRenderState camera, CallbackInfo ci) {
54
        ChestEsp.setCurrentGlow(0);
55
    }
56
}
57
BlockItemMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BlockItemMixin.javaJava · 32 lines · 1.3 KB
@Mixin(BlockItem.class)
ModifiesBlockItem
BlockItemMixin.javaJava · 32 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.world.NoGhostBlocks;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.item.BlockItem;
6
import net.minecraft.world.item.context.BlockPlaceContext;
7
import net.minecraft.world.level.block.state.BlockState;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
@Mixin(BlockItem.class)
14
public abstract class BlockItemMixin {
15
16
    // Reporting success keeps the swing and the stack shrink and the placement packet.
17
    @Inject(
18
        method = "placeBlock(Lnet/minecraft/world/item/context/BlockPlaceContext;Lnet/minecraft/world/level/block/state/BlockState;)Z",
19
        at = @At("HEAD"),
20
        cancellable = true)
21
    private void holdPlacement(BlockPlaceContext context, BlockState state,
22
                               CallbackInfoReturnable<Boolean> cir) {
23
        if (!context.getLevel().isClientSide()) {
24
            return;
25
        }
26
        NoGhostBlocks noGhostBlocks = Modules.get(NoGhostBlocks.class);
27
        if (noGhostBlocks != null && noGhostBlocks.holdsPlacements()) {
28
            cir.setReturnValue(true);
29
        }
30
    }
31
}
32
BlockStateBaseMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BlockStateBaseMixin.javaJava · 73 lines · 3.1 KB
@Mixin(BlockBehaviour.BlockStateBase.class)
BlockStateBaseMixin.javaJava · 73 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.player.GhostHand;
4
import com.jellypudding.offlineclient.modules.render.NoRender;
5
import com.jellypudding.offlineclient.modules.render.XRay;
6
import com.jellypudding.offlineclient.util.Modules;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.world.level.BlockGetter;
9
import net.minecraft.world.level.block.state.BlockBehaviour;
10
import net.minecraft.world.phys.Vec3;
11
import net.minecraft.world.phys.shapes.CollisionContext;
12
import net.minecraft.world.phys.shapes.Shapes;
13
import net.minecraft.world.phys.shapes.VoxelShape;
14
import org.spongepowered.asm.mixin.Mixin;
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.CallbackInfoReturnable;
19
20
@Mixin(BlockBehaviour.BlockStateBase.class)
21
public abstract class BlockStateBaseMixin {
22
23
    // No ambient occlusion shading whilst XRay is on.
24
    @Inject(
25
        method = "getShadeBrightness(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)F",
26
        at = @At("RETURN"),
27
        cancellable = true)
28
    private void onGetShadeBrightness(BlockGetter level, BlockPos pos, CallbackInfoReturnable<Float> cir) {
29
        XRay xray = XRay.get();
30
        if (xray != null && xray.isEnabled()) {
31
            cir.setReturnValue(1f);
32
        }
33
    }
34
35
    // GhostHand empties the outline of every block it cannot open. The
36
    // crosshair then reaches the container behind the wall.
37
    @Inject(
38
        method = "getShape(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/shapes/CollisionContext;)Lnet/minecraft/world/phys/shapes/VoxelShape;",
39
        at = @At("HEAD"), cancellable = true)
40
    private void onGetShape(BlockGetter level, BlockPos pos, CollisionContext context,
41
                            CallbackInfoReturnable<VoxelShape> cir) {
42
        if (context == CollisionContext.empty()) {
43
            return;
44
        }
45
        GhostHand ghostHand = Modules.get(GhostHand.class);
46
        if (ghostHand != null && ghostHand.passesThrough(pos)) {
47
            cir.setReturnValue(Shapes.empty());
48
        }
49
    }
50
51
    // The offset and the seed are what make grass and flowers sit differently in each spot.
52
    @Inject(method = "getOffset(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;",
53
        at = @At("HEAD"), cancellable = true)
54
    private void onGetOffset(BlockPos pos, CallbackInfoReturnable<Vec3> cir) {
55
        if (offlineclient$fixedRotations()) {
56
            cir.setReturnValue(Vec3.ZERO);
57
        }
58
    }
59
60
    @Inject(method = "getSeed(Lnet/minecraft/core/BlockPos;)J", at = @At("HEAD"), cancellable = true)
61
    private void onGetSeed(BlockPos pos, CallbackInfoReturnable<Long> cir) {
62
        if (offlineclient$fixedRotations()) {
63
            cir.setReturnValue(0L);
64
        }
65
    }
66
67
    @Unique
68
    private static boolean offlineclient$fixedRotations() {
69
        NoRender noRender = Modules.get(NoRender.class);
70
        return noRender != null && noRender.fixesTextureRotations();
71
    }
72
}
73
BossHealthOverlayMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BossHealthOverlayMixin.javaJava · 40 lines · 1.7 KB
@Mixin(BossHealthOverlay.class)
BossHealthOverlayMixin.javaJava · 40 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.BossStack;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.client.gui.components.BossHealthOverlay;
7
import net.minecraft.client.gui.components.LerpingBossEvent;
8
import net.minecraft.network.chat.Component;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
import org.spongepowered.asm.mixin.injection.Constant;
12
import org.spongepowered.asm.mixin.injection.ModifyConstant;
13
14
import java.util.Iterator;
15
16
@Mixin(BossHealthOverlay.class)
17
public abstract class BossHealthOverlayMixin {
18
19
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE",
20
        target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;"))
21
    private Iterator<LerpingBossEvent> onBars(Iterator<LerpingBossEvent> original) {
22
        BossStack stack = Modules.get(BossStack.class);
23
        return stack == null ? original : stack.bars(original);
24
    }
25
26
    @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE",
27
        target = "Lnet/minecraft/client/gui/components/LerpingBossEvent;getName()Lnet/minecraft/network/chat/Component;"))
28
    private Component onName(Component original) {
29
        BossStack stack = Modules.get(BossStack.class);
30
        return stack == null ? original : stack.name(original);
31
    }
32
33
    // Vanilla steps down ten pixels plus a line of text for each bar.
34
    @ModifyConstant(method = "extractRenderState", constant = @Constant(intValue = 10))
35
    private int onGap(int original) {
36
        BossStack stack = Modules.get(BossStack.class);
37
        return stack == null ? original : stack.gap();
38
    }
39
}
40
BrightnessGetterMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BrightnessGetterMixin.javaJava · 30 lines · 1.4 KB
@Mixin(LightCoordsUtil.BrightnessGetter.class)
BrightnessGetterMixin.javaJava · 30 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Fullbright;
4
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
5
import net.minecraft.util.LightCoordsUtil;
6
import net.minecraft.world.level.LightLayer;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
10
// Fullbright raises the light every block is lit with before it is packed.
11
@Mixin(LightCoordsUtil.BrightnessGetter.class)
12
public interface BrightnessGetterMixin {
13
14
    @ModifyExpressionValue(method = "lambda$static$0", at = @At(value = "INVOKE",
15
        target = "Lnet/minecraft/world/level/BlockAndLightGetter;getBrightness(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/BlockPos;)I",
16
        ordinal = 0))
17
    private static int onSkyLight(int sky) {
18
        Fullbright fullbright = Fullbright.get();
19
        return fullbright == null ? sky : Math.max(sky, fullbright.lightFloor(LightLayer.SKY));
20
    }
21
22
    @ModifyExpressionValue(method = "lambda$static$0", at = @At(value = "INVOKE",
23
        target = "Lnet/minecraft/world/level/BlockAndLightGetter;getBrightness(Lnet/minecraft/world/level/LightLayer;Lnet/minecraft/core/BlockPos;)I",
24
        ordinal = 1))
25
    private static int onBlockLight(int block) {
26
        Fullbright fullbright = Fullbright.get();
27
        return fullbright == null ? block : Math.max(block, fullbright.lightFloor(LightLayer.BLOCK));
28
    }
29
}
30
BundleMouseActionsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/BundleMouseActionsMixin.javaJava · 40 lines · 1.7 KB
@Mixin(BundleMouseActions.class)
BundleMouseActionsMixin.javaJava · 40 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.player.InventoryTweaks;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.client.gui.BundleMouseActions;
7
import net.minecraft.core.component.DataComponents;
8
import net.minecraft.world.item.ItemStack;
9
import net.minecraft.world.item.component.BundleContents;
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.injection.At;
12
13
// Vanilla only lets the scroll reach the few items a bundle draws.
14
@Mixin(BundleMouseActions.class)
15
public abstract class BundleMouseActionsMixin {
16
17
    private static final String SHOWN =
18
        "Lnet/minecraft/world/item/BundleItem;getNumberOfItemsToShow(Lnet/minecraft/world/item/ItemStack;)I";
19
20
    @ModifyExpressionValue(method = "toggleSelectedBundleItem",
21
        at = @At(value = "INVOKE", target = SHOWN))
22
    private int uncapToggle(int shown, ItemStack bundle, int slot, int selected) {
23
        return offlineclient$reach(shown, bundle);
24
    }
25
26
    @ModifyExpressionValue(method = "onMouseScrolled",
27
        at = @At(value = "INVOKE", target = SHOWN))
28
    private int uncapScroll(int shown, double scrollX, double scrollY, int slot, ItemStack bundle) {
29
        return offlineclient$reach(shown, bundle);
30
    }
31
32
    private static int offlineclient$reach(int shown, ItemStack bundle) {
33
        InventoryTweaks tweaks = Modules.get(InventoryTweaks.class);
34
        if (tweaks == null || !tweaks.uncapsBundles()) {
35
            return shown;
36
        }
37
        return bundle.getOrDefault(DataComponents.BUNDLE_CONTENTS, BundleContents.EMPTY).size();
38
    }
39
}
40
CameraMixinsrc/main/java/com/jellypudding/offlineclient/mixin/CameraMixin.javaJava · 116 lines · 4.9 KB
@Mixin(Camera.class)
ModifiesCamera
CameraMixin.javaJava · 116 lines · 4.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.CameraTweaks;
4
import com.jellypudding.offlineclient.modules.render.FreeLook;
5
import com.jellypudding.offlineclient.modules.render.Freecam;
6
import com.jellypudding.offlineclient.modules.render.NoRender;
7
import com.jellypudding.offlineclient.modules.render.WallHack;
8
import com.jellypudding.offlineclient.modules.render.XRay;
9
import com.jellypudding.offlineclient.modules.render.Zoom;
10
import com.jellypudding.offlineclient.util.Modules;
11
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
12
import net.minecraft.client.Camera;
13
import net.minecraft.client.DeltaTracker;
14
import net.minecraft.client.renderer.state.level.CameraRenderState;
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.injection.At;
19
import org.spongepowered.asm.mixin.injection.Inject;
20
import org.spongepowered.asm.mixin.injection.ModifyVariable;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
23
24
@Mixin(Camera.class)
25
public abstract class CameraMixin {
26
27
    @Shadow
28
    private boolean detached;
29
30
    @Shadow
31
    protected abstract void setPosition(Vec3 pos);
32
33
    @Shadow
34
    protected abstract void setRotation(float yaw, float pitch);
35
36
    // The world and the hand each read the field of view. One ease a frame keeps them level.
37
    @Inject(method = "update(Lnet/minecraft/client/DeltaTracker;)V", at = @At("HEAD"))
38
    private void onCameraUpdate(DeltaTracker deltaTracker, CallbackInfo ci) {
39
        Zoom zoom = Modules.get(Zoom.class);
40
        if (zoom != null) {
41
            zoom.advance();
42
        }
43
    }
44
45
    // FreeLook lends its look angles to the camera entity for the alignment call.
46
    @Inject(method = "update(Lnet/minecraft/client/DeltaTracker;)V",
47
        at = @At(value = "INVOKE",
48
            target = "Lnet/minecraft/client/Camera;alignWithEntity(F)V"))
49
    private void beforeAlignWithEntity(DeltaTracker deltaTracker, CallbackInfo ci) {
50
        FreeLook freeLook = Modules.get(FreeLook.class);
51
        if (freeLook != null) {
52
            freeLook.applyRotation();
53
        }
54
    }
55
56
    @Inject(method = "update(Lnet/minecraft/client/DeltaTracker;)V",
57
        at = @At(value = "INVOKE",
58
            target = "Lnet/minecraft/client/Camera;alignWithEntity(F)V",
59
            shift = At.Shift.AFTER))
60
    private void afterAlignWithEntity(DeltaTracker deltaTracker, CallbackInfo ci) {
61
        FreeLook freeLook = Modules.get(FreeLook.class);
62
        if (freeLook != null) {
63
            freeLook.restoreRotation();
64
        }
65
        Freecam freecam = Modules.active(Freecam.class);
66
        if (freecam == null) {
67
            return;
68
        }
69
        detached = true;
70
        float partialTicks = deltaTracker.getGameTimeDeltaPartialTick(true);
71
        setPosition(freecam.getCamPos(partialTicks));
72
        setRotation(freecam.getCamYaw(), freecam.getCamPitch());
73
    }
74
75
    // Vanilla skips chunk sections that are boxed in by solid ground.
76
    @Inject(method = "extractRenderState(Lnet/minecraft/client/renderer/state/level/CameraRenderState;F)V",
77
        at = @At("RETURN"))
78
    private void onExtractRenderState(CameraRenderState state, float partialTicks, CallbackInfo ci) {
79
        XRay xray = XRay.get();
80
        WallHack wallHack = Modules.get(WallHack.class);
81
        NoRender noRender = Modules.get(NoRender.class);
82
        if ((xray != null && xray.isEnabled()) || (wallHack != null && wallHack.showsHiddenChunks())
83
            || (noRender != null && noRender.skipsCaveCulling())) {
84
            state.smartCull = false;
85
        }
86
    }
87
88
    @ModifyReturnValue(method = "calculateFov(F)F", at = @At("RETURN"))
89
    private float onCalculateFov(float original) {
90
        Zoom zoom = Modules.get(Zoom.class);
91
        return zoom == null ? original : zoom.applyZoom(original);
92
    }
93
94
    @ModifyReturnValue(method = "calculateHudFov(F)F", at = @At("RETURN"))
95
    private float onCalculateHudFov(float original) {
96
        Zoom zoom = Modules.get(Zoom.class);
97
        return zoom == null ? original : zoom.applyZoom(original);
98
    }
99
100
    // The distance vanilla wants before it walks the ray out and shortens it.
101
    @ModifyVariable(method = "getMaxZoom(F)F", at = @At("HEAD"), argsOnly = true)
102
    private float onWantedZoom(float wanted) {
103
        CameraTweaks tweaks = Modules.get(CameraTweaks.class);
104
        return tweaks == null ? wanted : tweaks.adjustDistance(wanted);
105
    }
106
107
    // No clip returns the wanted distance whole and skips the ray walk.
108
    @Inject(method = "getMaxZoom(F)F", at = @At("HEAD"), cancellable = true)
109
    private void onGetMaxZoom(float wanted, CallbackInfoReturnable<Float> cir) {
110
        CameraTweaks tweaks = Modules.get(CameraTweaks.class);
111
        if (tweaks != null && tweaks.passesThroughWalls()) {
112
            cir.setReturnValue(tweaks.adjustDistance(wanted));
113
        }
114
    }
115
}
116
ChatBackgroundGraphicsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ChatBackgroundGraphicsMixin.javaJava · 59 lines · 2.6 KB
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$DrawingBackgroundGraphicsAccess")
ChatBackgroundGraphicsMixin.javaJava · 59 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterChat;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyReceiver;
6
import net.minecraft.client.gui.ActiveTextCollector;
7
import net.minecraft.client.gui.GuiGraphicsExtractor;
8
import net.minecraft.client.gui.TextAlignment;
9
import net.minecraft.util.ARGB;
10
import net.minecraft.util.FormattedCharSequence;
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.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.ModifyArg;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18
19
// The chat drawn whilst the chat screen is closed.
20
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$DrawingBackgroundGraphicsAccess")
21
public abstract class ChatBackgroundGraphicsMixin {
22
23
    private static final String ACCEPT = "Lnet/minecraft/client/gui/ActiveTextCollector;accept"
24
        + "(Lnet/minecraft/client/gui/TextAlignment;II"
25
        + "Lnet/minecraft/client/gui/ActiveTextCollector$Parameters;"
26
        + "Lnet/minecraft/util/FormattedCharSequence;)V";
27
28
    @Shadow
29
    @Final
30
    private GuiGraphicsExtractor graphics;
31
32
    // The head goes in the gap the widened chat left on the left.
33
    @ModifyReceiver(method = "handleMessage", at = @At(value = "INVOKE", target = ACCEPT))
34
    private ActiveTextCollector beforeText(ActiveTextCollector collector, TextAlignment alignment,
35
                                           int x, int y, ActiveTextCollector.Parameters parameters,
36
                                           FormattedCharSequence text) {
37
        BetterChat betterChat = Modules.get(BetterChat.class);
38
        if (betterChat != null) {
39
            betterChat.drawHead(graphics, y, ARGB.white(parameters.opacity()));
40
        }
41
        return collector;
42
    }
43
44
    @ModifyArg(method = "handleMessage", at = @At(value = "INVOKE", target = ACCEPT), index = 1)
45
    private int shiftText(int x) {
46
        BetterChat betterChat = Modules.get(BetterChat.class);
47
        return betterChat == null ? x : betterChat.textStart(x);
48
    }
49
50
    @Inject(method = "handleMessage", at = @At("TAIL"))
51
    private void afterText(int top, float opacity, FormattedCharSequence text,
52
                           CallbackInfoReturnable<Boolean> cir) {
53
        BetterChat betterChat = Modules.get(BetterChat.class);
54
        if (betterChat != null) {
55
            betterChat.endLine();
56
        }
57
    }
58
}
59
ChatComponentMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ChatComponentMixin.javaJava · 78 lines · 3.6 KB
@Mixin(ChatComponent.class)
ChatComponentMixin.javaJava · 78 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AntiSpam;
4
import com.jellypudding.offlineclient.modules.misc.BetterChat;
5
import com.jellypudding.offlineclient.modules.misc.NameProtect;
6
import com.jellypudding.offlineclient.util.Modules;
7
import net.minecraft.client.gui.components.ChatComponent;
8
import net.minecraft.client.multiplayer.chat.GuiMessageSource;
9
import net.minecraft.client.multiplayer.chat.GuiMessageTag;
10
import net.minecraft.network.chat.Component;
11
import net.minecraft.network.chat.MessageSignature;
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.ModifyVariable;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
18
19
@Mixin(ChatComponent.class)
20
public abstract class ChatComponentMixin {
21
22
    private static final String ADD_MESSAGE = "addMessage"
23
        + "(Lnet/minecraft/network/chat/Component;"
24
        + "Lnet/minecraft/network/chat/MessageSignature;"
25
        + "Lnet/minecraft/client/multiplayer/chat/GuiMessageSource;"
26
        + "Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)V";
27
28
    @Inject(method = ADD_MESSAGE, at = @At("HEAD"), cancellable = true)
29
    private void onAddMessage(Component message, MessageSignature signature,
30
                              GuiMessageSource source, GuiMessageTag tag, CallbackInfo ci) {
31
        BetterChat betterChat = Modules.get(BetterChat.class);
32
        if (betterChat != null && betterChat.filters(message)) {
33
            ci.cancel();
34
        }
35
    }
36
37
    @ModifyVariable(method = ADD_MESSAGE, at = @At("HEAD"), argsOnly = true)
38
    private Component rewriteMessage(Component message) {
39
        NameProtect nameProtect = Modules.get(NameProtect.class);
40
        if (nameProtect != null) {
41
            message = nameProtect.filter(message);
42
        }
43
        AntiSpam antiSpam = Modules.get(AntiSpam.class);
44
        if (antiSpam != null) {
45
            message = antiSpam.fold((ChatComponent) (Object) this, message);
46
        }
47
        BetterChat betterChat = Modules.get(BetterChat.class);
48
        return betterChat == null ? message : betterChat.decorate(message);
49
    }
50
51
    // Both queues trim to the same hundred lines.
52
    @ModifyExpressionValue(method = {"addMessageToDisplayQueue", "addMessageToQueue"},
53
        at = @At(value = "CONSTANT", args = "intValue=100"))
54
    private int historyLimit(int vanilla) {
55
        BetterChat betterChat = Modules.get(BetterChat.class);
56
        return betterChat == null ? vanilla : betterChat.historyLimit(vanilla);
57
    }
58
59
    // The width the lines are laid out in. A head needs room on the left.
60
    @ModifyExpressionValue(
61
        method = "extractRenderState(Lnet/minecraft/client/gui/components/ChatComponent$ChatGraphicsAccess;"
62
            + "IILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;)V",
63
        at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;ceil(F)I"))
64
    private int headRoom(int width) {
65
        BetterChat betterChat = Modules.get(BetterChat.class);
66
        return betterChat == null ? width : betterChat.headRoom(width);
67
    }
68
69
    // Called on a disconnect and by the debug clear key.
70
    @Inject(method = "clearMessages(Z)V", at = @At("HEAD"), cancellable = true)
71
    private void onClearMessages(boolean history, CallbackInfo ci) {
72
        BetterChat betterChat = Modules.get(BetterChat.class);
73
        if (betterChat != null && betterChat.keepsHistory()) {
74
            ci.cancel();
75
        }
76
    }
77
}
78
ChatFocusedGraphicsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ChatFocusedGraphicsMixin.javaJava · 58 lines · 2.5 KB
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$DrawingFocusedGraphicsAccess")
ChatFocusedGraphicsMixin.javaJava · 58 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterChat;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyReceiver;
6
import net.minecraft.client.gui.ActiveTextCollector;
7
import net.minecraft.client.gui.GuiGraphicsExtractor;
8
import net.minecraft.client.gui.TextAlignment;
9
import net.minecraft.util.ARGB;
10
import net.minecraft.util.FormattedCharSequence;
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.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.ModifyArg;
17
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18
19
// The chat drawn whilst the chat screen is open.
20
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$DrawingFocusedGraphicsAccess")
21
public abstract class ChatFocusedGraphicsMixin {
22
23
    private static final String ACCEPT = "Lnet/minecraft/client/gui/ActiveTextCollector;accept"
24
        + "(Lnet/minecraft/client/gui/TextAlignment;II"
25
        + "Lnet/minecraft/client/gui/ActiveTextCollector$Parameters;"
26
        + "Lnet/minecraft/util/FormattedCharSequence;)V";
27
28
    @Shadow
29
    @Final
30
    private GuiGraphicsExtractor graphics;
31
32
    @ModifyReceiver(method = "handleMessage", at = @At(value = "INVOKE", target = ACCEPT))
33
    private ActiveTextCollector beforeText(ActiveTextCollector collector, TextAlignment alignment,
34
                                           int x, int y, ActiveTextCollector.Parameters parameters,
35
                                           FormattedCharSequence text) {
36
        BetterChat betterChat = Modules.get(BetterChat.class);
37
        if (betterChat != null) {
38
            betterChat.drawHead(graphics, y, ARGB.white(parameters.opacity()));
39
        }
40
        return collector;
41
    }
42
43
    @ModifyArg(method = "handleMessage", at = @At(value = "INVOKE", target = ACCEPT), index = 1)
44
    private int shiftText(int x) {
45
        BetterChat betterChat = Modules.get(BetterChat.class);
46
        return betterChat == null ? x : betterChat.textStart(x);
47
    }
48
49
    @Inject(method = "handleMessage", at = @At("TAIL"))
50
    private void afterText(int top, float opacity, FormattedCharSequence text,
51
                           CallbackInfoReturnable<Boolean> cir) {
52
        BetterChat betterChat = Modules.get(BetterChat.class);
53
        if (betterChat != null) {
54
            betterChat.endLine();
55
        }
56
    }
57
}
58
ChatLineConsumerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ChatLineConsumerMixin.javaJava · 35 lines · 1.7 KB
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$1")
ChatLineConsumerMixin.javaJava · 35 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterChat;
4
import com.jellypudding.offlineclient.modules.render.ClearView;
5
import com.jellypudding.offlineclient.util.Modules;
6
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
7
import net.minecraft.client.multiplayer.chat.GuiMessage;
8
import net.minecraft.client.multiplayer.chat.GuiMessageTag;
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
14
// The consumer that draws each chat line. The tag paints the signature bar on the left.
15
@Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$1")
16
public abstract class ChatLineConsumerMixin {
17
18
    // The lines arrive top down. BetterChat needs to know which one is being drawn.
19
    @Inject(method = "accept(Lnet/minecraft/client/multiplayer/chat/GuiMessage$Line;IF)V",
20
        at = @At("HEAD"))
21
    private void onLine(GuiMessage.Line line, int index, float alpha, CallbackInfo ci) {
22
        BetterChat betterChat = Modules.get(BetterChat.class);
23
        if (betterChat != null) {
24
            betterChat.beginLine(line, index);
25
        }
26
    }
27
28
    @ModifyExpressionValue(method = "accept(Lnet/minecraft/client/multiplayer/chat/GuiMessage$Line;IF)V",
29
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/chat/GuiMessage$Line;tag()Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;"))
30
    private GuiMessageTag onLineTag(GuiMessageTag tag) {
31
        ClearView clearView = Modules.active(ClearView.class);
32
        return clearView != null && clearView.blocksSignatureBar() ? null : tag;
33
    }
34
}
35
ChatScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ChatScreenMixin.javaJava · 241 lines · 9.7 KB
@Mixin(ChatScreen.class)
ModifiesChatScreen
ChatScreenMixin.javaJava · 241 lines · 9.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.jellypudding.offlineclient.modules.misc.BetterChat;
6
import com.jellypudding.offlineclient.modules.render.Blur;
7
import com.jellypudding.offlineclient.event.events.ChatSendEvent;
8
import com.jellypudding.offlineclient.gui.ChatScrollBar;
9
import net.minecraft.client.gui.GuiGraphicsExtractor;
10
import net.minecraft.client.gui.components.EditBox;
11
import net.minecraft.client.gui.screens.ChatScreen;
12
import net.minecraft.client.gui.screens.Screen;
13
import net.minecraft.client.input.KeyEvent;
14
import net.minecraft.client.input.MouseButtonEvent;
15
import net.minecraft.network.chat.Component;
16
import org.lwjgl.glfw.GLFW;
17
import org.spongepowered.asm.mixin.Mixin;
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
import java.util.List;
26
27
@Mixin(ChatScreen.class)
28
public abstract class ChatScreenMixin extends Screen {
29
30
    private ChatScreenMixin(OfflineClient client, Component title) {
31
        super(title);
32
    }
33
34
    @Shadow
35
    public abstract String normalizeChatMessage(String message);
36
37
    @Shadow
38
    protected EditBox input;
39
40
    // Which of the shown completions the arrow keys have picked.
41
    @Unique
42
    private int offlineclient$picked;
43
44
    // The text the pick was made for. Typing anything else starts over at the top.
45
    @Unique
46
    private String offlineclient$pickedFor = "";
47
48
    @Unique
49
    private final ChatScrollBar offlineclient$scrollBar = new ChatScrollBar();
50
51
    @Unique
52
    private static boolean offlineclient$scrollBarOn() {
53
        BetterChat betterChat = Modules.get(BetterChat.class);
54
        return betterChat != null && betterChat.showsScrollbar();
55
    }
56
57
    @Inject(method = "mouseClicked(Lnet/minecraft/client/input/MouseButtonEvent;Z)Z",
58
        at = @At("HEAD"), cancellable = true)
59
    private void onMouseClicked(MouseButtonEvent event, boolean doubleClick,
60
                                CallbackInfoReturnable<Boolean> cir) {
61
        if (event.button() == 0 && offlineclient$scrollBarOn()
62
            && offlineclient$scrollBar.mouseClicked(event.x(), event.y(), height)) {
63
            cir.setReturnValue(true);
64
        }
65
    }
66
67
    @Override
68
    public boolean mouseDragged(MouseButtonEvent event, double dragX, double dragY) {
69
        return offlineclient$scrollBar.mouseDragged(event.y(), height)
70
            || super.mouseDragged(event, dragX, dragY);
71
    }
72
73
    @Override
74
    public boolean mouseReleased(MouseButtonEvent event) {
75
        offlineclient$scrollBar.mouseReleased();
76
        return super.mouseReleased(event);
77
    }
78
79
    // Vanilla completion only knows server commands.
80
    // Tab takes the picked completion and up or down arrows move the pick through the list.
81
    @Inject(method = "keyPressed(Lnet/minecraft/client/input/KeyEvent;)Z",
82
        at = @At("HEAD"),
83
        cancellable = true)
84
    private void onTabComplete(KeyEvent event, CallbackInfoReturnable<Boolean> cir) {
85
        int key = event.key();
86
        if (key != GLFW.GLFW_KEY_TAB && key != GLFW.GLFW_KEY_UP && key != GLFW.GLFW_KEY_DOWN) {
87
            return;
88
        }
89
        String text = input.getValue();
90
        String prefix = OfflineClient.INSTANCE.getCommandManager().getPrefix();
91
        if (!text.startsWith(prefix) || text.length() <= prefix.length()) {
92
            return;
93
        }
94
        List<String> options = OfflineClient.INSTANCE.getCommandManager().complete(text);
95
        // With nothing to choose between the arrows keep walking the chat history.
96
        if (options.isEmpty() || (key != GLFW.GLFW_KEY_TAB && options.size() < 2)) {
97
            return;
98
        }
99
        cir.setReturnValue(true);
100
        int picked = offlineclient$pickFor(text, options.size());
101
102
        if (key == GLFW.GLFW_KEY_UP || key == GLFW.GLFW_KEY_DOWN) {
103
            offlineclient$picked = Math.floorMod(picked + (key == GLFW.GLFW_KEY_DOWN ? 1 : -1), options.size());
104
            return;
105
        }
106
107
        int lastSpace = text.lastIndexOf(' ');
108
        String head = lastSpace == -1 ? prefix : text.substring(0, lastSpace + 1);
109
        String typed = text.substring(head.length());
110
        String common = offlineclient$commonPrefix(options);
111
        // A pick or a single match completes whole. Otherwise the shared start fills in first.
112
        if (options.size() == 1 || picked > 0 || common.length() <= typed.length()) {
113
            input.setValue(head + options.get(picked) + " ");
114
        } else {
115
            input.setValue(head + common);
116
        }
117
        input.moveCursorToEnd(false);
118
    }
119
120
    // The pick for this text. Any change to the text puts it back on the first option.
121
    @Unique
122
    private int offlineclient$pickFor(String text, int count) {
123
        if (!text.equals(offlineclient$pickedFor)) {
124
            offlineclient$pickedFor = text;
125
            offlineclient$picked = 0;
126
        }
127
        offlineclient$picked = Math.min(offlineclient$picked, count - 1);
128
        return offlineclient$picked;
129
    }
130
131
    // The chat draws no background of its own. The blur has to be asked for here.
132
    @Inject(method = "extractBackground(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
133
        at = @At("HEAD"))
134
    private void onExtractBackground(GuiGraphicsExtractor context, int mouseX, int mouseY,
135
                                     float partialTicks, CallbackInfo ci) {
136
        Blur blur = Modules.get(Blur.class);
137
        if (blur != null && blur.wants((Screen) (Object) this)) {
138
            blur.blurHere(context);
139
        }
140
    }
141
142
    @Inject(method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
143
        at = @At("TAIL"))
144
    private void onRender(GuiGraphicsExtractor context, int mouseX, int mouseY,
145
                          float partialTicks, CallbackInfo ci) {
146
        if (offlineclient$scrollBarOn()) {
147
            offlineclient$scrollBar.render(context, mouseX, mouseY);
148
        }
149
        String text = input == null ? "" : input.getValue();
150
        String prefix = OfflineClient.INSTANCE.getCommandManager().getPrefix();
151
        if (!text.startsWith(prefix) || text.length() <= prefix.length()) {
152
            return;
153
        }
154
        List<String> options = OfflineClient.INSTANCE.getCommandManager().complete(text);
155
        if (options.isEmpty()) {
156
            return;
157
        }
158
159
        int picked = offlineclient$pickFor(text, options.size());
160
        // The list scrolls to keep the pick among the rows shown.
161
        int shown = Math.min(8, options.size());
162
        int first = Math.clamp(picked - shown + 1, 0, options.size() - shown);
163
        String overflow = options.size() > shown
164
            ? "and " + (options.size() - shown) + " more" : null;
165
        int boxWidth = overflow == null ? 0 : minecraft.font.width(overflow);
166
        for (int i = first; i < first + shown; i++) {
167
            boxWidth = Math.max(boxWidth, minecraft.font.width(options.get(i)));
168
        }
169
        int x = 4;
170
        int bottom = height - 16;
171
        int top = bottom - shown * 10 - 2;
172
        // The overflow line sits a row above the options and needs covering too.
173
        context.fill(x - 2, overflow == null ? top - 2 : top - 14,
174
            x + boxWidth + 4, bottom, 0xE8101018);
175
        context.guiRenderState.up();
176
        for (int i = 0; i < shown; i++) {
177
            int index = first + i;
178
            context.text(minecraft.font, options.get(index), x, top + i * 10,
179
                index == picked ? 0xFF00E5FF : 0xFFB0B0C0, false);
180
        }
181
        if (overflow != null) {
182
            context.text(minecraft.font, overflow, x, top - 12, 0xFF707080, false);
183
        }
184
    }
185
186
    @Unique
187
    private static String offlineclient$commonPrefix(List<String> options) {
188
        String common = options.get(0);
189
        for (String option : options) {
190
            int i = 0;
191
            while (i < common.length() && i < option.length()
192
                && Character.toLowerCase(common.charAt(i)) == Character.toLowerCase(option.charAt(i))) {
193
                i++;
194
            }
195
            common = common.substring(0, i);
196
        }
197
        return common;
198
    }
199
200
    @Inject(method = "init", at = @At("TAIL"))
201
    private void onInit(CallbackInfo ci) {
202
        BetterChat betterChat = Modules.get(BetterChat.class);
203
        if (betterChat != null && betterChat.liftsBoxLimit()) {
204
            input.setMaxLength(Integer.MAX_VALUE);
205
        }
206
    }
207
208
    @Inject(method = "handleChatInput(Ljava/lang/String;Z)V",
209
        at = @At("HEAD"),
210
        cancellable = true)
211
    private void onSendMessage(String message, boolean addToHistory, CallbackInfo ci) {
212
        if ((message = normalizeChatMessage(message)).isEmpty()) {
213
            return;
214
        }
215
216
        ChatSendEvent event = new ChatSendEvent(message);
217
        OfflineClient.INSTANCE.getEventBus().post(event);
218
        if (event.isCancelled()) {
219
            // The command goes into chat history but never to the server.
220
            ci.cancel();
221
            if (addToHistory) {
222
                minecraft.gui.hud.getChat().addRecentChat(message);
223
            }
224
            return;
225
        }
226
227
        BetterChat betterChat = Modules.get(BetterChat.class);
228
        String rewritten = betterChat == null ? message : betterChat.rewrite(message);
229
        if (rewritten.equals(message)) {
230
            return;
231
        }
232
233
        // The typed line is what goes into the history. The dressed one goes to the server.
234
        ci.cancel();
235
        if (addToHistory) {
236
            minecraft.gui.hud.getChat().addRecentChat(message);
237
        }
238
        minecraft.player.connection.sendChat(rewritten);
239
    }
240
}
241
ClientClockManagerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ClientClockManagerMixin.javaJava · 27 lines · 1.1 KB
@Mixin(ClientClockManager.class)
ClientClockManagerMixin.javaJava · 27 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.TimeChanger;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.ClientClockManager;
6
import net.minecraft.core.Holder;
7
import net.minecraft.world.clock.WorldClock;
8
import net.minecraft.world.clock.WorldClocks;
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.CallbackInfoReturnable;
13
14
@Mixin(ClientClockManager.class)
15
public abstract class ClientClockManagerMixin {
16
17
    // The sky and the moon and every clock item read the day through here.
18
    @Inject(method = "getTotalTicks(Lnet/minecraft/core/Holder;)J", at = @At("HEAD"),
19
        cancellable = true)
20
    private void onGetTotalTicks(Holder<WorldClock> clock, CallbackInfoReturnable<Long> cir) {
21
        TimeChanger timeChanger = Modules.active(TimeChanger.class);
22
        if (timeChanger != null && clock.is(WorldClocks.OVERWORLD)) {
23
            cir.setReturnValue(timeChanger.clockTime());
24
        }
25
    }
26
}
27
ClientInputMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ClientInputMixin.javaJava · 28 lines · 1.1 KB
@Mixin(ClientInput.class)
ModifiesClientInput
ClientInputMixin.javaJava · 28 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.movement.Sprint;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.player.ClientInput;
6
import net.minecraft.world.phys.Vec2;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.Shadow;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
@Mixin(ClientInput.class)
14
public abstract class ClientInputMixin {
15
16
    @Shadow
17
    protected Vec2 moveVector;
18
19
    // Every sprint check asks this. A sideways step counts as forward whilst Sprint allows it.
20
    @Inject(method = "hasForwardImpulse()Z", at = @At("HEAD"), cancellable = true)
21
    private void onHasForwardImpulse(CallbackInfoReturnable<Boolean> cir) {
22
        Sprint sprint = Modules.get(Sprint.class);
23
        if (sprint != null && sprint.sprintsAnyDirection() && moveVector.lengthSquared() > 1e-5f) {
24
            cir.setReturnValue(true);
25
        }
26
    }
27
}
28
ClientLevelMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ClientLevelMixin.javaJava · 70 lines · 3.2 KB
@Mixin(ClientLevel.class)
ModifiesClientLevel
ClientLevelMixin.javaJava · 70 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.VehicleTickEvent;
5
import com.jellypudding.offlineclient.modules.render.ClearView;
6
import com.jellypudding.offlineclient.modules.render.NoRender;
7
import com.jellypudding.offlineclient.util.Modules;
8
import net.minecraft.client.multiplayer.ClientLevel;
9
import net.minecraft.client.player.LocalPlayer;
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.core.Direction;
12
import net.minecraft.core.particles.ParticleTypes;
13
import net.minecraft.world.entity.Entity;
14
import net.minecraft.world.level.block.Block;
15
import net.minecraft.world.level.block.Blocks;
16
import net.minecraft.world.level.block.state.BlockState;
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
24
@Mixin(ClientLevel.class)
25
public abstract class ClientLevelMixin {
26
27
    // The vehicle ticks before its riders. This is the last word before it moves.
28
    @Inject(method = "tickNonPassenger(Lnet/minecraft/world/entity/Entity;)V",
29
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;tick()V"))
30
    private void onVehicleTick(Entity entity, CallbackInfo ci) {
31
        LocalPlayer player = OfflineClient.MC.player;
32
        if (player != null && player.isPassenger() && entity == player.getRootVehicle()) {
33
            OfflineClient.INSTANCE.getEventBus().post(new VehicleTickEvent(entity));
34
        }
35
    }
36
37
    // Vanilla only names the barrier whilst a creative player holds one.
38
    @Inject(method = "getMarkerParticleTarget()Lnet/minecraft/world/level/block/Block;",
39
        at = @At("RETURN"), cancellable = true)
40
    private void onMarkerParticleTarget(CallbackInfoReturnable<Block> cir) {
41
        NoRender noRender = Modules.get(NoRender.class);
42
        if (cir.getReturnValue() == null && noRender != null && noRender.showsBarriers()) {
43
            cir.setReturnValue(Blocks.BARRIER);
44
        }
45
    }
46
47
    // Block crumbs are made here and never pass through the particle engine's options path.
48
    @Inject(method = "addDestroyBlockEffect(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V",
49
        at = @At("HEAD"), cancellable = true)
50
    private void onDestroyBlockEffect(BlockPos pos, BlockState state, CallbackInfo ci) {
51
        if (offlineclient$blocksBlockParticles()) {
52
            ci.cancel();
53
        }
54
    }
55
56
    @Inject(method = "addBreakingBlockEffect(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)V",
57
        at = @At("HEAD"), cancellable = true)
58
    private void onBreakingBlockEffect(BlockPos pos, Direction side, CallbackInfo ci) {
59
        if (offlineclient$blocksBlockParticles()) {
60
            ci.cancel();
61
        }
62
    }
63
64
    @Unique
65
    private static boolean offlineclient$blocksBlockParticles() {
66
        ClearView clearView = Modules.active(ClearView.class);
67
        return clearView != null && clearView.blocksParticle(ParticleTypes.BLOCK);
68
    }
69
}
70
ClientPacketListenerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ClientPacketListenerMixin.javaJava · 129 lines · 5.4 KB
@Mixin(ClientPacketListener.class)
ClientPacketListenerMixin.javaJava · 129 lines · 5.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.EntityAddedEvent;
5
import com.jellypudding.offlineclient.modules.player.NoRotate;
6
import com.jellypudding.offlineclient.modules.render.NewChunks;
7
import com.jellypudding.offlineclient.modules.render.NoRender;
8
import com.jellypudding.offlineclient.util.Modules;
9
import net.minecraft.client.multiplayer.ClientPacketListener;
10
import net.minecraft.client.player.LocalPlayer;
11
import net.minecraft.world.entity.Entity;
12
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
13
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
14
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
15
import net.minecraft.network.protocol.game.ClientboundPlayerRotationPacket;
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
22
@Mixin(ClientPacketListener.class)
23
public abstract class ClientPacketListenerMixin {
24
25
    // Dropped on the network thread before the packet is handed to the main thread.
26
    @Inject(method = "handleAddEntity(Lnet/minecraft/network/protocol/game/ClientboundAddEntityPacket;)V",
27
        at = @At("HEAD"), cancellable = true)
28
    private void onDropAddEntity(ClientboundAddEntityPacket packet, CallbackInfo ci) {
29
        NoRender noRender = Modules.get(NoRender.class);
30
        if (noRender != null && noRender.dropsSpawnPacket(packet.getType())) {
31
            ci.cancel();
32
        }
33
    }
34
35
    // Runs once on the network thread to bounce to the main thread. Only the main run has the entity.
36
    @Inject(method = "handleAddEntity(Lnet/minecraft/network/protocol/game/ClientboundAddEntityPacket;)V",
37
        at = @At("TAIL"))
38
    private void onAddEntity(ClientboundAddEntityPacket packet, CallbackInfo ci) {
39
        if (!OfflineClient.MC.isSameThread() || OfflineClient.MC.level == null) {
40
            return;
41
        }
42
        Entity entity = OfflineClient.MC.level.getEntity(packet.getId());
43
        if (entity != null) {
44
            OfflineClient.INSTANCE.getEventBus().post(new EntityAddedEvent(entity));
45
        }
46
    }
47
48
    @Unique
49
    private float offlineclient$savedYaw;
50
    @Unique
51
    private float offlineclient$savedPitch;
52
53
    // Packet handlers run once on the network thread to bounce onto the main thread.
54
    // Only the main thread run touches the player.
55
    @Unique
56
    private boolean offlineclient$noRotateActive() {
57
        if (!OfflineClient.MC.isSameThread() || OfflineClient.MC.player == null) {
58
            return false;
59
        }
60
        return Modules.enabled(NoRotate.class);
61
    }
62
63
    @Unique
64
    private void offlineclient$saveRotation() {
65
        LocalPlayer player = OfflineClient.MC.player;
66
        offlineclient$savedYaw = player.getYRot();
67
        offlineclient$savedPitch = player.getXRot();
68
    }
69
70
    // The tiny offset makes the next position update carry a rotation.
71
    @Unique
72
    private void offlineclient$restoreRotation() {
73
        LocalPlayer player = OfflineClient.MC.player;
74
        player.setYRot(offlineclient$savedYaw + 0.000001f);
75
        player.setXRot(offlineclient$savedPitch + 0.000001f);
76
        player.yHeadRot = offlineclient$savedYaw;
77
        player.yBodyRot = offlineclient$savedYaw;
78
    }
79
80
    // The chunk is in the world and every later packet is still queued behind this one.
81
    // NewChunks reads the liquid here whilst the data is untouched.
82
    @Inject(
83
        method = "handleLevelChunkWithLight"
84
            + "(Lnet/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket;)V",
85
        at = @At("TAIL"))
86
    private void onChunkLoaded(ClientboundLevelChunkWithLightPacket packet, CallbackInfo ci) {
87
        NewChunks newChunks = Modules.get(NewChunks.class);
88
        if (newChunks != null) {
89
            newChunks.onChunkLoaded(packet.getX(), packet.getZ());
90
        }
91
    }
92
93
    @Inject(
94
        method = "handleMovePlayer(Lnet/minecraft/network/protocol/game/ClientboundPlayerPositionPacket;)V",
95
        at = @At("HEAD"))
96
    private void onMovePlayerHead(ClientboundPlayerPositionPacket packet, CallbackInfo ci) {
97
        if (offlineclient$noRotateActive()) {
98
            offlineclient$saveRotation();
99
        }
100
    }
101
102
    @Inject(
103
        method = "handleMovePlayer(Lnet/minecraft/network/protocol/game/ClientboundPlayerPositionPacket;)V",
104
        at = @At("RETURN"))
105
    private void onMovePlayerReturn(ClientboundPlayerPositionPacket packet, CallbackInfo ci) {
106
        if (offlineclient$noRotateActive()) {
107
            offlineclient$restoreRotation();
108
        }
109
    }
110
111
    @Inject(
112
        method = "handleRotatePlayer(Lnet/minecraft/network/protocol/game/ClientboundPlayerRotationPacket;)V",
113
        at = @At("HEAD"))
114
    private void onRotatePlayerHead(ClientboundPlayerRotationPacket packet, CallbackInfo ci) {
115
        if (offlineclient$noRotateActive()) {
116
            offlineclient$saveRotation();
117
        }
118
    }
119
120
    @Inject(
121
        method = "handleRotatePlayer(Lnet/minecraft/network/protocol/game/ClientboundPlayerRotationPacket;)V",
122
        at = @At("RETURN"))
123
    private void onRotatePlayerReturn(ClientboundPlayerRotationPacket packet, CallbackInfo ci) {
124
        if (offlineclient$noRotateActive()) {
125
            offlineclient$restoreRotation();
126
        }
127
    }
128
}
129
CompressionDecoderMixinsrc/main/java/com/jellypudding/offlineclient/mixin/CompressionDecoderMixin.javaJava · 20 lines · 854 B
@Mixin(CompressionDecoder.class)
CompressionDecoderMixin.javaJava · 20 lines · 854 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AntiPacketKick;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.network.CompressionDecoder;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
10
// Vanilla drops the connection when an uncompressed packet is over eight megabytes.
11
@Mixin(CompressionDecoder.class)
12
public abstract class CompressionDecoderMixin {
13
14
    @ModifyExpressionValue(method = "decode", at = @At(value = "CONSTANT", args = "intValue=8388608"))
15
    private int liftSizeLimit(int vanilla) {
16
        AntiPacketKick module = Modules.get(AntiPacketKick.class);
17
        return module != null && module.acceptsHugePackets() ? Integer.MAX_VALUE : vanilla;
18
    }
19
}
20
ConnectScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ConnectScreenMixin.javaJava · 27 lines · 1.2 KB
@Mixin(ConnectScreen.class)
ConnectScreenMixin.javaJava · 27 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AutoReconnect;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.gui.screens.ConnectScreen;
6
import net.minecraft.client.gui.screens.Screen;
7
import net.minecraft.client.multiplayer.ServerData;
8
import net.minecraft.client.multiplayer.TransferState;
9
import net.minecraft.client.multiplayer.resolver.ServerAddress;
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
15
// The server is noted on every join. AutoReconnect then knows where to go even
16
// when it was switched on after the disconnect.
17
@Mixin(ConnectScreen.class)
18
public abstract class ConnectScreenMixin {
19
20
    @Inject(method = "startConnecting", at = @At("HEAD"))
21
    private static void onStartConnecting(Screen parent, Minecraft minecraft, ServerAddress address,
22
                                          ServerData server, boolean quickPlay,
23
                                          TransferState transfer, CallbackInfo ci) {
24
        AutoReconnect.remember(server);
25
    }
26
}
27
ConnectionMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ConnectionMixin.javaJava · 106 lines · 4.8 KB
@Mixin(Connection.class)
ModifiesConnection
ConnectionMixin.javaJava · 106 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.PacketReceiveEvent;
5
import com.jellypudding.offlineclient.event.events.PacketSendEvent;
6
import com.jellypudding.offlineclient.modules.misc.AntiPacketKick;
7
import com.jellypudding.offlineclient.util.ChatUtil;
8
import com.jellypudding.offlineclient.util.Modules;
9
import com.jellypudding.offlineclient.util.PacketUtil;
10
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
11
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
12
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
13
import io.netty.channel.ChannelFutureListener;
14
import io.netty.channel.ChannelHandlerContext;
15
import io.netty.channel.SimpleChannelInboundHandler;
16
import io.netty.handler.timeout.TimeoutException;
17
import net.minecraft.network.Connection;
18
import net.minecraft.network.PacketListener;
19
import net.minecraft.network.SkipPacketEncoderException;
20
import net.minecraft.network.protocol.Packet;
21
import net.minecraft.network.protocol.game.ClientGamePacketListener;
22
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
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.ModifyVariable;
27
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28
29
import java.util.ArrayList;
30
import java.util.List;
31
32
@Mixin(Connection.class)
33
public abstract class ConnectionMixin extends SimpleChannelInboundHandler<Packet<?>> {
34
35
    // Bundles carry several packets in one wrapper.
36
    @ModifyVariable(
37
        method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;)V",
38
        at = @At("HEAD"),
39
        argsOnly = true)
40
    private Packet<?> unpackBundle(Packet<?> packet) {
41
        PacketUtil.noteConnection((Connection) (Object) this);
42
        if (!(packet instanceof ClientboundBundlePacket bundle)) {
43
            return packet;
44
        }
45
        List<Packet<? super ClientGamePacketListener>> kept = new ArrayList<>();
46
        boolean changed = false;
47
        for (Packet<? super ClientGamePacketListener> sub : bundle.subPackets()) {
48
            PacketReceiveEvent event = new PacketReceiveEvent(sub);
49
            OfflineClient.INSTANCE.getEventBus().post(event);
50
            if (event.isCancelled()) {
51
                changed = true;
52
            } else {
53
                @SuppressWarnings("unchecked")
54
                Packet<? super ClientGamePacketListener> result =
55
                    (Packet<? super ClientGamePacketListener>) event.getPacket();
56
                changed |= result != sub;
57
                kept.add(result);
58
            }
59
        }
60
        return changed ? new ClientboundBundlePacket(kept) : packet;
61
    }
62
63
    @WrapOperation(
64
        method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;)V",
65
        at = @At(value = "INVOKE",
66
            target = "Lnet/minecraft/network/Connection;genericsFtw(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;)V"))
67
    private void wrapHandle(Packet<?> packet, PacketListener listener, Operation<Void> original) {
68
        // Bundles already had an event each in unpackBundle.
69
        if (packet instanceof ClientboundBundlePacket) {
70
            original.call(packet, listener);
71
            return;
72
        }
73
        PacketReceiveEvent event = new PacketReceiveEvent(packet);
74
        OfflineClient.INSTANCE.getEventBus().post(event);
75
        if (event.isCancelled()) {
76
            return;
77
        }
78
        original.call(event.getPacket(), listener);
79
    }
80
81
    // A timeout still has to disconnect. Anything else can be thrown away.
82
    @Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
83
    private void onExceptionCaught(ChannelHandlerContext context, Throwable cause, CallbackInfo ci) {
84
        AntiPacketKick module = Modules.get(AntiPacketKick.class);
85
        if (module == null || !module.catchesErrors()
86
            || cause instanceof TimeoutException || cause instanceof SkipPacketEncoderException) {
87
            return;
88
        }
89
        if (module.logsErrors()) {
90
            ChatUtil.error("Dropped a packet the client could not read: " + cause);
91
        }
92
        ci.cancel();
93
    }
94
95
    @WrapMethod(
96
        method = "send(Lnet/minecraft/network/protocol/Packet;Lio/netty/channel/ChannelFutureListener;)V")
97
    private void wrapSend(Packet<?> packet, ChannelFutureListener callback, Operation<Void> original) {
98
        PacketSendEvent event = new PacketSendEvent(packet);
99
        OfflineClient.INSTANCE.getEventBus().post(event);
100
        if (event.isCancelled()) {
101
            return;
102
        }
103
        original.call(event.getPacket(), callback);
104
    }
105
}
106
DeathScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/DeathScreenMixin.javaJava · 39 lines · 1.5 KB
@Mixin(DeathScreen.class)
ModifiesDeathScreen
DeathScreenMixin.javaJava · 39 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.player.AutoRespawn;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.gui.components.Button;
6
import net.minecraft.client.gui.screens.DeathScreen;
7
import net.minecraft.client.gui.screens.Screen;
8
import net.minecraft.network.chat.Component;
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
14
// A button under the vanilla pair that switches AutoRespawn on from the death screen.
15
@Mixin(DeathScreen.class)
16
public abstract class DeathScreenMixin extends Screen {
17
18
    private static final int BUTTON_WIDTH = 200;
19
    private static final int BUTTON_HEIGHT = 20;
20
    // The vanilla buttons sit at a quarter of the height plus 72 and 96.
21
    private static final int BUTTON_TOP = 120;
22
23
    private DeathScreenMixin(Component title) {
24
        super(title);
25
    }
26
27
    @Inject(method = "init", at = @At("TAIL"))
28
    private void onInit(CallbackInfo ci) {
29
        AutoRespawn module = Modules.get(AutoRespawn.class);
30
        if (module == null || module.isEnabled() || !module.showsButton()) {
31
            return;
32
        }
33
        addRenderableWidget(Button.builder(Component.literal("Turn AutoRespawn on"),
34
                button -> module.setEnabled(true))
35
            .bounds((width - BUTTON_WIDTH) / 2, height / 4 + BUTTON_TOP, BUTTON_WIDTH, BUTTON_HEIGHT)
36
            .build());
37
    }
38
}
39
DeltaTrackerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/DeltaTrackerMixin.javaJava · 31 lines · 1.0 KB
@Mixin(DeltaTracker.Timer.class)
DeltaTrackerMixin.javaJava · 31 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.Timer;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.DeltaTracker;
6
import org.objectweb.asm.Opcodes;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.Shadow;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
@Mixin(DeltaTracker.Timer.class)
14
public abstract class DeltaTrackerMixin {
15
16
    @Shadow
17
    public float deltaTicks;
18
19
    @Inject(method = "advanceGameTime(J)I",
20
        at = @At(value = "FIELD",
21
            target = "Lnet/minecraft/client/DeltaTracker$Timer;lastMs:J",
22
            opcode = Opcodes.PUTFIELD,
23
            ordinal = 0))
24
    private void onAdvanceGameTime(long timeMillis, CallbackInfoReturnable<Integer> cir) {
25
        Timer timer = Modules.get(Timer.class);
26
        if (timer != null) {
27
            deltaTicks *= timer.getSpeed();
28
        }
29
    }
30
}
31
DisconnectedScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/DisconnectedScreenMixin.javaJava · 67 lines · 2.6 KB
@Mixin(DisconnectedScreen.class)
DisconnectedScreenMixin.javaJava · 67 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AutoReconnect;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.gui.components.Button;
6
import net.minecraft.client.gui.screens.DisconnectedScreen;
7
import net.minecraft.client.gui.screens.Screen;
8
import net.minecraft.network.chat.Component;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.Unique;
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
15
// Two rows under the vanilla buttons. A disconnect can be answered by hand.
16
@Mixin(DisconnectedScreen.class)
17
public abstract class DisconnectedScreenMixin extends Screen {
18
19
    private static final int BUTTON_WIDTH = 200;
20
    private static final int BUTTON_HEIGHT = 20;
21
22
    private DisconnectedScreenMixin(Component title) {
23
        super(title);
24
    }
25
26
    @Unique
27
    private Button offlineclient$reconnect;
28
29
    @Unique
30
    private Button offlineclient$toggle;
31
32
    @Inject(method = "init", at = @At("TAIL"))
33
    private void onInit(CallbackInfo ci) {
34
        AutoReconnect module = Modules.get(AutoReconnect.class);
35
        if (module == null || !module.showsButtons() || !AutoReconnect.canReconnect()) {
36
            return;
37
        }
38
        int x = (width - BUTTON_WIDTH) / 2;
39
        offlineclient$reconnect = addRenderableWidget(
40
            Button.builder(Component.literal("Reconnect"), button -> module.reconnectNow())
41
                .bounds(x, height - 52, BUTTON_WIDTH, BUTTON_HEIGHT).build());
42
        offlineclient$toggle = addRenderableWidget(
43
            Button.builder(offlineclient$toggleText(module), button -> {
44
                module.toggleFromScreen();
45
                offlineclient$toggle.setMessage(offlineclient$toggleText(module));
46
            }).bounds(x, height - 28, BUTTON_WIDTH, BUTTON_HEIGHT).build());
47
    }
48
49
    @Unique
50
    private static Component offlineclient$toggleText(AutoReconnect module) {
51
        return Component.literal("Auto reconnect " + (module.isEnabled() ? "on" : "off"));
52
    }
53
54
    // The countdown reads live. The button says how long is left.
55
    @Override
56
    public void tick() {
57
        super.tick();
58
        AutoReconnect module = Modules.get(AutoReconnect.class);
59
        if (offlineclient$reconnect == null || module == null) {
60
            return;
61
        }
62
        double left = module.secondsLeft();
63
        offlineclient$reconnect.setMessage(Component.literal(
64
            left < 0 ? "Reconnect" : "Reconnect (" + left + ")"));
65
    }
66
}
67
EnchantTableRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EnchantTableRendererMixin.javaJava · 31 lines · 1.5 KB
@Mixin(EnchantTableRenderer.class)
EnchantTableRendererMixin.javaJava · 31 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.renderer.SubmitNodeCollector;
7
import net.minecraft.client.renderer.blockentity.EnchantTableRenderer;
8
import net.minecraft.client.renderer.blockentity.state.EnchantTableRenderState;
9
import net.minecraft.client.renderer.state.level.CameraRenderState;
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
15
// The table itself is an ordinary block model. This renderer only draws the book.
16
@Mixin(EnchantTableRenderer.class)
17
public abstract class EnchantTableRendererMixin {
18
19
    @Inject(method = "submit(Lnet/minecraft/client/renderer/blockentity/state/EnchantTableRenderState;"
20
        + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;"
21
        + "Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
22
        at = @At("HEAD"), cancellable = true)
23
    private void onSubmit(EnchantTableRenderState state, PoseStack poseStack, SubmitNodeCollector collector,
24
                          CameraRenderState camera, CallbackInfo ci) {
25
        NoRender noRender = Modules.get(NoRender.class);
26
        if (noRender != null && noRender.hidesEnchantingBook()) {
27
            ci.cancel();
28
        }
29
    }
30
}
31
EndCrystalModelMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EndCrystalModelMixin.javaJava · 41 lines · 1.8 KB
@Mixin(EndCrystalModel.class)
EndCrystalModelMixin.javaJava · 41 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Chams;
4
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
5
import net.minecraft.client.model.object.crystal.EndCrystalModel;
6
import net.minecraft.client.renderer.entity.state.EndCrystalRenderState;
7
import net.minecraft.util.Mth;
8
import org.objectweb.asm.Opcodes;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
12
// Chams changes how far a crystal bobs and how fast it turns.
13
@Mixin(EndCrystalModel.class)
14
public abstract class EndCrystalModelMixin {
15
16
    // The vanilla bob curve with its height scaled.
17
    @ModifyExpressionValue(
18
        method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;)V",
19
        at = @At(value = "INVOKE",
20
            target = "Lnet/minecraft/client/renderer/entity/EndCrystalRenderer;getY(F)F"))
21
    private float onBounce(float original, EndCrystalRenderState state) {
22
        Chams chams = Chams.get();
23
        if (chams == null || !chams.reshapesCrystals()) {
24
            return original;
25
        }
26
        float wave = Mth.sin(state.ageInTicks * 0.2f) / 2f + 0.5f;
27
        return (wave * wave + wave) * 0.4f * chams.crystalBounce() - 1.4f;
28
    }
29
30
    // The first read of the age feeds the spin angle.
31
    @ModifyExpressionValue(
32
        method = "setupAnim(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;)V",
33
        at = @At(value = "FIELD",
34
            target = "Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;ageInTicks:F",
35
            opcode = Opcodes.GETFIELD, ordinal = 0))
36
    private float onSpin(float original) {
37
        Chams chams = Chams.get();
38
        return chams == null || !chams.reshapesCrystals() ? original : original * chams.crystalSpin();
39
    }
40
}
41
EndCrystalRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EndCrystalRendererMixin.javaJava · 54 lines · 3.2 KB
@Mixin(EndCrystalRenderer.class)
EndCrystalRendererMixin.javaJava · 54 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Chams;
4
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
5
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
6
import com.mojang.blaze3d.vertex.PoseStack;
7
import net.minecraft.client.model.Model;
8
import net.minecraft.client.renderer.SubmitNodeCollector;
9
import net.minecraft.client.renderer.entity.EndCrystalRenderer;
10
import net.minecraft.client.renderer.entity.state.EndCrystalRenderState;
11
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
12
import net.minecraft.client.renderer.rendertype.RenderTypes;
13
import net.minecraft.client.renderer.state.level.CameraRenderState;
14
import net.minecraft.resources.Identifier;
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
// Chams resizes and recolours end crystals.
21
@Mixin(EndCrystalRenderer.class)
22
public abstract class EndCrystalRendererMixin {
23
24
    @Inject(
25
        method = "submit(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
26
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;scale(FFF)V"))
27
    private void onScale(EndCrystalRenderState state, PoseStack poseStack, SubmitNodeCollector collector,
28
                         CameraRenderState camera, CallbackInfo ci) {
29
        Chams chams = Chams.get();
30
        if (chams != null && chams.reshapesCrystals()) {
31
            float scale = chams.crystalScale();
32
            poseStack.scale(scale, scale, scale);
33
        }
34
    }
35
36
    @WrapOperation(
37
        method = "submit(Lnet/minecraft/client/renderer/entity/state/EndCrystalRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
38
        at = @At(value = "INVOKE",
39
            target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/resources/Identifier;IIILnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V"))
40
    private <S> void onSubmitModel(SubmitNodeCollector collector, Model<? super S> model, S state,
41
                                   PoseStack poseStack, Identifier texture, int light, int overlay,
42
                                   int outline, ModelFeatureRenderer.CrumblingOverlay crumbling,
43
                                   Operation<Void> original) {
44
        Chams chams = Chams.get();
45
        if (chams == null || !chams.reshapesCrystals()) {
46
            original.call(collector, model, state, poseStack, texture, light, overlay, outline, crumbling);
47
            return;
48
        }
49
        collector.submitModel(model, state, poseStack,
50
            RenderTypes.entityTranslucent(chams.crystalTexture(texture)),
51
            light, overlay, chams.crystalColor(), null, outline, crumbling);
52
    }
53
}
54
EntityFluidInteractionMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EntityFluidInteractionMixin.javaJava · 28 lines · 1.3 KB
@Mixin(EntityFluidInteraction.class)
EntityFluidInteractionMixin.javaJava · 28 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.AntiPush;
5
import com.jellypudding.offlineclient.util.Modules;
6
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.entity.EntityFluidInteraction;
9
import net.minecraft.world.phys.Vec3;
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.injection.At;
12
13
@Mixin(EntityFluidInteraction.class)
14
public abstract class EntityFluidInteractionMixin {
15
16
    // Every current a fluid pulls with is summed from this flow. AntiPush keeps a share of it.
17
    @ModifyExpressionValue(method = "update(Lnet/minecraft/world/entity/Entity;Z)V",
18
        at = @At(value = "INVOKE",
19
            target = "Lnet/minecraft/world/level/material/FluidState;getFlow(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;"))
20
    private Vec3 onFluidFlow(Vec3 flow, Entity entity, boolean ignoreCurrent) {
21
        if (entity != OfflineClient.MC.player) {
22
            return flow;
23
        }
24
        AntiPush antiPush = Modules.get(AntiPush.class);
25
        return antiPush == null ? flow : antiPush.scaleCurrent(flow);
26
    }
27
}
28
EntityMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EntityMixin.javaJava · 107 lines · 4.8 KB
@Mixin(Entity.class)
ModifiesEntity
EntityMixin.javaJava · 107 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.combat.Hitboxes;
5
import com.jellypudding.offlineclient.modules.movement.AntiPush;
6
import com.jellypudding.offlineclient.modules.movement.Flight;
7
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
8
import com.jellypudding.offlineclient.modules.movement.NoFall;
9
import com.jellypudding.offlineclient.modules.movement.Step;
10
import com.jellypudding.offlineclient.modules.render.NoRender;
11
import com.jellypudding.offlineclient.util.Modules;
12
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
13
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
14
import net.minecraft.core.Direction;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.phys.Vec3;
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.ModifyArg;
22
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
23
24
@Mixin(Entity.class)
25
public abstract class EntityMixin {
26
27
    @Shadow
28
    public boolean verticalCollisionBelow;
29
30
    // The pick radius inflates the box the crosshair tests against.
31
    @Inject(method = "getPickRadius", at = @At("HEAD"), cancellable = true)
32
    private void onGetPickRadius(CallbackInfoReturnable<Float> cir) {
33
        Hitboxes hitboxes = Modules.get(Hitboxes.class);
34
        if (hitboxes == null) {
35
            return;
36
        }
37
        double extra = hitboxes.expansionFor((Entity) (Object) this);
38
        if (extra > 0) {
39
            cir.setReturnValue((float) extra);
40
        }
41
    }
42
43
    @Inject(method = "isCurrentlyGlowing()Z", at = @At("HEAD"), cancellable = true)
44
    private void onIsCurrentlyGlowing(CallbackInfoReturnable<Boolean> cir) {
45
        NoRender noRender = Modules.get(NoRender.class);
46
        if (noRender != null && noRender.hidesGlowing()) {
47
            cir.setReturnValue(false);
48
        }
49
    }
50
51
    // Flight through fluids and NoSlowdown fluid drag. The local player is never in
52
    // water or lava as far as the physics and the swimming pose are concerned.
53
    @Inject(method = {"isInWater()Z", "isInLava()Z", "isUnderWater()Z"},
54
        at = @At("HEAD"), cancellable = true)
55
    private void onFluidCheck(CallbackInfoReturnable<Boolean> cir) {
56
        if ((Object) this != OfflineClient.MC.player) {
57
            return;
58
        }
59
        Flight flight = Modules.active(Flight.class);
60
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
61
        if ((flight != null && flight.throughFluids())
62
            || (noSlowdown != null && noSlowdown.skipsFluidDrag())) {
63
            cir.setReturnValue(false);
64
        }
65
    }
66
67
    // Slime and beds ask this before they bounce. NoFall answers yes to every landing.
68
    @Inject(method = "isSuppressingBounce()Z", at = @At("HEAD"), cancellable = true)
69
    private void onIsSuppressingBounce(CallbackInfoReturnable<Boolean> cir) {
70
        if ((Object) this != OfflineClient.MC.player) {
71
            return;
72
        }
73
        NoFall noFall = Modules.get(NoFall.class);
74
        if (noFall != null && noFall.suppressesBounce()) {
75
            cir.setReturnValue(true);
76
        }
77
    }
78
79
    // A crowd shove reaches the player only through this call. AntiPush keeps a share of it.
80
    @WrapOperation(method = "push(Lnet/minecraft/world/entity/Entity;)V",
81
        at = @At(value = "INVOKE",
82
            target = "Lnet/minecraft/world/entity/Entity;push(DDD)V"))
83
    private void onPushedByEntity(Entity pushed, double x, double y, double z,
84
                                  Operation<Void> original) {
85
        AntiPush antiPush = pushed == OfflineClient.MC.player ? Modules.get(AntiPush.class) : null;
86
        double scale = antiPush == null ? 1 : antiPush.entityPushScale();
87
        original.call(pushed, x * scale, y, z * scale);
88
    }
89
90
    // Step raising the step height makes a stepped landing look like a big collision.
91
    // That would launch the player off slime or a bed. The y component is zeroed here.
92
    @ModifyArg(method = "move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V",
93
        at = @At(value = "INVOKE",
94
            target = "Lnet/minecraft/world/entity/Entity;restituteMovementAfterCollisions(Lnet/minecraft/world/level/block/state/BlockState;ZZLnet/minecraft/world/phys/Vec3;)V"),
95
        index = 3)
96
    private Vec3 flattenSteppedLanding(Vec3 collided) {
97
        if ((Object) this != OfflineClient.MC.player || !verticalCollisionBelow || collided.y <= 0) {
98
            return collided;
99
        }
100
        Step step = Modules.get(Step.class);
101
        if (step == null || !step.raisesStepHeight()) {
102
            return collided;
103
        }
104
        return collided.with(Direction.Axis.Y, 0);
105
    }
106
}
107
EntityRenderStateMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EntityRenderStateMixin.javaJava · 68 lines · 1.6 KB
@Mixin(EntityRenderState.class)
EntityRenderStateMixin.javaJava · 68 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.mixinterface.IRenderState;
4
import net.minecraft.client.renderer.entity.state.EntityRenderState;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.Unique;
7
8
@Mixin(EntityRenderState.class)
9
public class EntityRenderStateMixin implements IRenderState {
10
11
    @Unique
12
    private int offlineclient$tint;
13
    @Unique
14
    private boolean offlineclient$chams;
15
    @Unique
16
    private boolean offlineclient$flat;
17
    @Unique
18
    private boolean offlineclient$forceVisible;
19
20
    @Override
21
    public void offlineclient$clear() {
22
        offlineclient$tint = 0;
23
        offlineclient$chams = false;
24
        offlineclient$flat = false;
25
        offlineclient$forceVisible = false;
26
    }
27
28
    @Override
29
    public int offlineclient$getTint() {
30
        return offlineclient$tint;
31
    }
32
33
    @Override
34
    public void offlineclient$setTint(int tint) {
35
        offlineclient$tint = tint;
36
    }
37
38
    @Override
39
    public boolean offlineclient$isChams() {
40
        return offlineclient$chams;
41
    }
42
43
    @Override
44
    public void offlineclient$setChams(boolean chams) {
45
        offlineclient$chams = chams;
46
    }
47
48
    @Override
49
    public boolean offlineclient$isFlat() {
50
        return offlineclient$flat;
51
    }
52
53
    @Override
54
    public void offlineclient$setFlat(boolean flat) {
55
        offlineclient$flat = flat;
56
    }
57
58
    @Override
59
    public boolean offlineclient$isForceVisible() {
60
        return offlineclient$forceVisible;
61
    }
62
63
    @Override
64
    public void offlineclient$setForceVisible(boolean forceVisible) {
65
        offlineclient$forceVisible = forceVisible;
66
    }
67
}
68
EntityRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EntityRendererMixin.javaJava · 79 lines · 3.5 KB
@Mixin(EntityRenderer.class)
EntityRendererMixin.javaJava · 79 lines · 3.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.mixinterface.IRenderState;
4
import com.jellypudding.offlineclient.modules.misc.FakePlayer;
5
import com.jellypudding.offlineclient.modules.misc.NameProtect;
6
import com.jellypudding.offlineclient.modules.render.Chams;
7
import com.jellypudding.offlineclient.modules.render.Esp;
8
import com.jellypudding.offlineclient.modules.render.NoRender;
9
import com.jellypudding.offlineclient.modules.render.TrueSight;
10
import com.jellypudding.offlineclient.util.Modules;
11
import net.minecraft.client.renderer.entity.EntityRenderer;
12
import net.minecraft.client.renderer.culling.Frustum;
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.CallbackInfo;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
20
21
@Mixin(EntityRenderer.class)
22
public abstract class EntityRendererMixin {
23
24
    // The Blink copy would fill the screen whilst you still stand where it was made.
25
    @Inject(
26
        method = "shouldRender(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/culling/Frustum;DDD)Z",
27
        at = @At("HEAD"), cancellable = true)
28
    private void onShouldRender(Entity entity, Frustum frustum, double x, double y, double z,
29
                                CallbackInfoReturnable<Boolean> cir) {
30
        if (entity instanceof FakePlayer.Body body && body.hidesAroundCamera()
31
            && body.getBoundingBox().contains(x, y, z)) {
32
            cir.setReturnValue(false);
33
            return;
34
        }
35
        NoRender noRender = Modules.get(NoRender.class);
36
        if (noRender != null && noRender.hidesEntity(entity)) {
37
            cir.setReturnValue(false);
38
        }
39
    }
40
41
    @Inject(
42
        method = "extractRenderState(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/entity/state/EntityRenderState;F)V",
43
        at = @At("TAIL"))
44
    private void onExtractRenderState(Entity entity, EntityRenderState state,
45
                                      float partialTicks, CallbackInfo ci) {
46
        // Render states are pooled and still carry last frame's flags.
47
        IRenderState extra = (IRenderState) state;
48
        extra.offlineclient$clear();
49
50
        Esp esp = Modules.get(Esp.class);
51
        if (esp != null && esp.shouldGlow(entity)) {
52
            state.outlineColor = esp.glowColor(entity);
53
        }
54
55
        Chams chams = Modules.get(Chams.class);
56
        if (chams != null && chams.applies(entity)) {
57
            extra.offlineclient$setChams(chams.throughWalls());
58
            extra.offlineclient$setFlat(chams.flat(entity));
59
            extra.offlineclient$setTint(chams.tintFor(entity));
60
        }
61
62
        TrueSight trueSight = Modules.get(TrueSight.class);
63
        if (trueSight != null && trueSight.applies(entity)) {
64
            extra.offlineclient$setForceVisible(true);
65
            extra.offlineclient$setTint(trueSight.tint());
66
        }
67
68
        NoRender noRender = Modules.get(NoRender.class);
69
        if (noRender != null && noRender.hidesNametags()) {
70
            state.nameTag = null;
71
        }
72
        // The vanilla tag over a head carries whatever the server wrote there.
73
        NameProtect nameProtect = Modules.get(NameProtect.class);
74
        if (nameProtect != null && state.nameTag != null) {
75
            state.nameTag = nameProtect.filter(state.nameTag);
76
        }
77
    }
78
}
79
EquipmentLayerRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/EquipmentLayerRendererMixin.javaJava · 23 lines · 903 B
@Mixin(EquipmentLayerRenderer.class)
EquipmentLayerRendererMixin.javaJava · 23 lines · 903 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer;
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.CallbackInfo;
10
11
@Mixin(EquipmentLayerRenderer.class)
12
public abstract class EquipmentLayerRendererMixin {
13
14
    // Every worn piece on every entity goes through one of the two overloads.
15
    @Inject(method = "renderLayers", at = @At("HEAD"), cancellable = true)
16
    private void onRenderLayers(CallbackInfo ci) {
17
        NoRender noRender = Modules.get(NoRender.class);
18
        if (noRender != null && noRender.hidesArmour()) {
19
            ci.cancel();
20
        }
21
    }
22
}
23
FallingBlockRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FallingBlockRendererMixin.javaJava · 29 lines · 1.4 KB
@Mixin(FallingBlockRenderer.class)
FallingBlockRendererMixin.javaJava · 29 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.renderer.SubmitNodeCollector;
7
import net.minecraft.client.renderer.entity.FallingBlockRenderer;
8
import net.minecraft.client.renderer.entity.state.FallingBlockRenderState;
9
import net.minecraft.client.renderer.state.level.CameraRenderState;
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
15
@Mixin(FallingBlockRenderer.class)
16
public abstract class FallingBlockRendererMixin {
17
18
    @Inject(method = "submit(Lnet/minecraft/client/renderer/entity/state/FallingBlockRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
19
        at = @At("HEAD"), cancellable = true)
20
    private void onSubmit(FallingBlockRenderState state, PoseStack poseStack,
21
                          SubmitNodeCollector collector, CameraRenderState camera,
22
                          CallbackInfo ci) {
23
        NoRender noRender = Modules.get(NoRender.class);
24
        if (noRender != null && noRender.hidesFallingBlocks()) {
25
            ci.cancel();
26
        }
27
    }
28
}
29
FireworkParticleMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FireworkParticleMixin.javaJava · 28 lines · 1.1 KB
@Mixin(targets = { "net.minecraft.client.particle.FireworkParticles$SparkParticle", "net.minecraft.client.particle.FireworkParticles$OverlayParticle" })
FireworkParticleMixin.javaJava · 28 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.Camera;
6
import net.minecraft.client.renderer.state.level.QuadParticleRenderState;
7
import org.spongepowered.asm.mixin.Mixin;
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
12
// The burst is made of sparks and a flash overlay. Both are private classes and both are skipped.
13
@Mixin(targets = {
14
    "net.minecraft.client.particle.FireworkParticles$SparkParticle",
15
    "net.minecraft.client.particle.FireworkParticles$OverlayParticle"
16
})
17
public abstract class FireworkParticleMixin {
18
19
    @Inject(method = "extract", at = @At("HEAD"), cancellable = true)
20
    private void onExtract(QuadParticleRenderState state, Camera camera, float partialTicks,
21
                           CallbackInfo ci) {
22
        NoRender noRender = Modules.get(NoRender.class);
23
        if (noRender != null && noRender.hidesFireworks()) {
24
            ci.cancel();
25
        }
26
    }
27
}
28
FireworkRocketEntityMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FireworkRocketEntityMixin.javaJava · 59 lines · 2.0 KB
@Mixin(FireworkRocketEntity.class)
FireworkRocketEntityMixin.javaJava · 59 lines · 2.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.movement.ElytraBoost;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
6
import net.minecraft.world.phys.BlockHitResult;
7
import net.minecraft.world.phys.EntityHitResult;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.Shadow;
10
import org.spongepowered.asm.mixin.Unique;
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
15
// A client side rocket has no server copy to remove it. It goes when its
16
// flight is over and never bursts on anything it touches.
17
@Mixin(FireworkRocketEntity.class)
18
public abstract class FireworkRocketEntityMixin {
19
20
    @Shadow
21
    private int life;
22
23
    @Shadow
24
    private int lifetime;
25
26
    @Inject(method = "tick()V", at = @At("TAIL"))
27
    private void discardSpentFake(CallbackInfo ci) {
28
        if (life > lifetime && offlineclient$isFake()) {
29
            ((FireworkRocketEntity) (Object) this).discard();
30
        }
31
    }
32
33
    @Inject(method = "onHitEntity(Lnet/minecraft/world/phys/EntityHitResult;)V",
34
        at = @At("HEAD"), cancellable = true)
35
    private void onHitEntity(EntityHitResult hit, CallbackInfo ci) {
36
        offlineclient$discardFake(ci);
37
    }
38
39
    @Inject(method = "onHitBlock(Lnet/minecraft/world/phys/BlockHitResult;)V",
40
        at = @At("HEAD"), cancellable = true)
41
    private void onHitBlock(BlockHitResult hit, CallbackInfo ci) {
42
        offlineclient$discardFake(ci);
43
    }
44
45
    @Unique
46
    private void offlineclient$discardFake(CallbackInfo ci) {
47
        if (offlineclient$isFake()) {
48
            ((FireworkRocketEntity) (Object) this).discard();
49
            ci.cancel();
50
        }
51
    }
52
53
    @Unique
54
    private boolean offlineclient$isFake() {
55
        ElytraBoost boost = Modules.get(ElytraBoost.class);
56
        return boost != null && boost.isFake((FireworkRocketEntity) (Object) this);
57
    }
58
}
59
FishingHookMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FishingHookMixin.javaJava · 27 lines · 1.0 KB
@Mixin(FishingHook.class)
ModifiesFishingHook
FishingHookMixin.javaJava · 27 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.NoKnockback;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.world.entity.Entity;
7
import net.minecraft.world.entity.projectile.FishingHook;
8
import org.spongepowered.asm.mixin.Mixin;
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
13
@Mixin(FishingHook.class)
14
public abstract class FishingHookMixin {
15
16
    // A rod reeling the player in lands here on the client.
17
    @Inject(method = "pullEntity(Lnet/minecraft/world/entity/Entity;)V",
18
        at = @At("HEAD"), cancellable = true)
19
    private void onPullEntity(Entity entity, CallbackInfo ci) {
20
        NoKnockback noKnockback = Modules.get(NoKnockback.class);
21
        if (entity == OfflineClient.MC.player && noKnockback != null
22
            && noKnockback.blocksFishingRods()) {
23
            ci.cancel();
24
        }
25
    }
26
}
27
FluidRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FluidRendererMixin.javaJava · 88 lines · 4.1 KB
@Mixin(FluidRenderer.class)
FluidRendererMixin.javaJava · 88 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.modules.render.XRay;
5
import com.jellypudding.offlineclient.util.Modules;
6
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
7
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
8
import net.minecraft.client.renderer.block.BlockAndTintGetter;
9
import net.minecraft.client.renderer.block.FluidRenderer;
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.core.Direction;
12
import net.minecraft.util.ARGB;
13
import net.minecraft.world.level.block.state.BlockState;
14
import net.minecraft.world.level.material.FluidState;
15
import net.minecraft.tags.FluidTags;
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.ModifyArg;
21
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22
23
// XRay hooks for water and lava plus the Ambience lava tint.
24
@Mixin(FluidRenderer.class)
25
public abstract class FluidRendererMixin {
26
27
    // Set whilst the fluid being built is lava the module recolours.
28
    @Unique
29
    private static final ThreadLocal<Boolean> OFFLINECLIENT_LAVA =
30
        ThreadLocal.withInitial(() -> false);
31
32
    @Inject(
33
        method = "tesselate(Lnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/client/renderer/block/FluidRenderer$Output;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/material/FluidState;)V",
34
        at = @At("HEAD"),
35
        cancellable = true)
36
    private void onTesselate(BlockAndTintGetter level, BlockPos pos, FluidRenderer.Output output,
37
                             BlockState blockState, FluidState fluidState, CallbackInfo ci) {
38
        Ambience ambience = Modules.get(Ambience.class);
39
        OFFLINECLIENT_LAVA.set(ambience != null && ambience.paintsLava()
40
            && fluidState.is(FluidTags.LAVA));
41
        int alpha = XRay.meshAlphaFor(level, fluidState.createLegacyBlock(), null);
42
        XRay.setMeshAlpha(alpha);
43
        if (alpha == 0) {
44
            ci.cancel();
45
        }
46
    }
47
48
    // A wanted fluid keeps its faces against hidden blocks.
49
    @WrapOperation(
50
        method = "tesselate(Lnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/client/renderer/block/FluidRenderer$Output;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/material/FluidState;)V",
51
        at = @At(value = "INVOKE",
52
            target = "Lnet/minecraft/client/renderer/block/FluidRenderer;isFaceOccludedByNeighbor(Lnet/minecraft/core/Direction;FLnet/minecraft/world/level/block/state/BlockState;)Z"))
53
    private boolean onFaceOccluded(Direction side, float height, BlockState neighborState,
54
                                   Operation<Boolean> original, BlockAndTintGetter level, BlockPos pos,
55
                                   FluidRenderer.Output output, BlockState blockState, FluidState fluidState) {
56
        boolean occluded = original.call(side, height, neighborState);
57
        if (!occluded) {
58
            return false;
59
        }
60
        XRay xray = XRay.get();
61
        if (xray == null || !xray.isEnabled()) {
62
            return true;
63
        }
64
        if (!xray.isVisible(fluidState.createLegacyBlock().getBlock())) {
65
            return true;
66
        }
67
        return xray.isVisible(neighborState.getBlock());
68
    }
69
70
    @ModifyArg(
71
        method = "vertex(Lcom/mojang/blaze3d/vertex/VertexConsumer;FFFIFFI)V",
72
        at = @At(value = "INVOKE",
73
            target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;addVertex(FFFIFFIIFFF)V"),
74
        index = 3)
75
    private int onVertexColor(int color) {
76
        if (OFFLINECLIENT_LAVA.get()) {
77
            Ambience ambience = Modules.get(Ambience.class);
78
            if (ambience != null) {
79
                color = ambience.lavaColor();
80
            }
81
        }
82
        if (!XRay.meshingTranslucent()) {
83
            return color;
84
        }
85
        return ARGB.color(XRay.meshAlpha(), ARGB.red(color), ARGB.green(color), ARGB.blue(color));
86
    }
87
}
88
FogRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FogRendererMixin.javaJava · 67 lines · 2.7 KB
@Mixin(FogRenderer.class)
ModifiesFogRenderer
FogRendererMixin.javaJava · 67 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.modules.render.ClearView;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.client.Camera;
7
import net.minecraft.world.level.material.FogType;
8
import net.minecraft.client.DeltaTracker;
9
import net.minecraft.client.multiplayer.ClientLevel;
10
import net.minecraft.client.renderer.fog.FogData;
11
import net.minecraft.client.renderer.fog.FogRenderer;
12
import net.minecraft.util.ARGB;
13
import org.joml.Vector4f;
14
import org.spongepowered.asm.mixin.Mixin;
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.ModifyVariable;
19
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
20
21
@Mixin(FogRenderer.class)
22
public class FogRendererMixin {
23
24
    // Far past any render distance. Nothing inside the world ever fades.
25
    @Unique
26
    private static final float OFFLINECLIENT_FAR = 1.0E7f;
27
28
    // The colour every fog band is drawn in.
29
    @ModifyVariable(
30
        method = "updateBuffer(Ljava/nio/ByteBuffer;ILorg/joml/Vector4f;FFFFFF)V",
31
        at = @At("HEAD"), argsOnly = true)
32
    private Vector4f recolourFog(Vector4f vanilla) {
33
        Ambience ambience = Modules.get(Ambience.class);
34
        if (ambience == null || !ambience.paintsFog()) {
35
            return vanilla;
36
        }
37
        int colour = ambience.fogColor();
38
        return new Vector4f(ARGB.red(colour) / 255f, ARGB.green(colour) / 255f,
39
            ARGB.blue(colour) / 255f, 1f);
40
    }
41
42
    @Inject(method = "setupFog", at = @At("RETURN"))
43
    private void onSetupFog(Camera camera, int renderDistance, DeltaTracker deltaTracker,
44
                            float skyDarken, ClientLevel level,
45
                            CallbackInfoReturnable<FogData> cir) {
46
        ClearView clearView = Modules.active(ClearView.class);
47
        if (clearView == null) {
48
            return;
49
        }
50
        // The blue underwater is mostly the short water fog. Pushing it away clears the tint.
51
        boolean underwater = clearView.blocksWater() && camera.getFluidInCamera() == FogType.WATER;
52
        if (!clearView.blocksFog() && !underwater) {
53
            return;
54
        }
55
        FogData data = cir.getReturnValue();
56
        if (data == null) {
57
            return;
58
        }
59
        data.environmentalStart = OFFLINECLIENT_FAR;
60
        data.environmentalEnd = OFFLINECLIENT_FAR;
61
        data.renderDistanceStart = OFFLINECLIENT_FAR;
62
        data.renderDistanceEnd = OFFLINECLIENT_FAR;
63
        data.skyEnd = OFFLINECLIENT_FAR;
64
        data.cloudEnd = OFFLINECLIENT_FAR;
65
    }
66
}
67
FontMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FontMixin.javaJava · 25 lines · 1.0 KB
@Mixin(Font.class)
ModifiesFont
FontMixin.javaJava · 25 lines · 1.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ClearView;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.client.gui.Font;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
10
@Mixin(Font.class)
11
public abstract class FontMixin {
12
13
    // Scrambled text picks a random glyph each frame. Plain text keeps its own.
14
    @ModifyExpressionValue(method = "getGlyph(ILnet/minecraft/network/chat/Style;)Lnet/minecraft/client/gui/font/glyphs/BakedGlyph;",
15
        at = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/Style;isObfuscated()Z"))
16
    private boolean onIsObfuscated(boolean obfuscated) {
17
        // Asked for every glyph drawn. Plain text must not reach the module lookup.
18
        if (!obfuscated) {
19
            return false;
20
        }
21
        ClearView clearView = Modules.active(ClearView.class);
22
        return clearView == null || !clearView.blocksMagicText();
23
    }
24
}
25
FoodDataMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FoodDataMixin.javaJava · 26 lines · 1.1 KB
@Mixin(FoodData.class)
ModifiesFoodData
FoodDataMixin.javaJava · 26 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
4
import com.jellypudding.offlineclient.modules.movement.Sprint;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.world.food.FoodData;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.Inject;
10
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11
12
@Mixin(FoodData.class)
13
public abstract class FoodDataMixin {
14
15
    // The only thing the client asks this for is whether sprinting is allowed.
16
    @Inject(method = "hasEnoughFood()Z", at = @At("HEAD"), cancellable = true)
17
    private void onHasEnoughFood(CallbackInfoReturnable<Boolean> cir) {
18
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
19
        Sprint sprint = Modules.get(Sprint.class);
20
        if ((noSlowdown != null && noSlowdown.skipsHunger())
21
            || (sprint != null && sprint.sprintsHungry())) {
22
            cir.setReturnValue(true);
23
        }
24
    }
25
}
26
FriendlyByteBufMixinsrc/main/java/com/jellypudding/offlineclient/mixin/FriendlyByteBufMixin.javaJava · 23 lines · 1.1 KB
@Mixin(FriendlyByteBuf.class)
FriendlyByteBufMixin.javaJava · 23 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AntiPacketKick;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.nbt.NbtAccounter;
6
import net.minecraft.network.FriendlyByteBuf;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.ModifyArg;
10
11
// The two megabyte tracker refuses an oversized tag and kills the connection.
12
@Mixin(FriendlyByteBuf.class)
13
public abstract class FriendlyByteBufMixin {
14
15
    @ModifyArg(method = "readNbt(Lio/netty/buffer/ByteBuf;)Lnet/minecraft/nbt/CompoundTag;",
16
        at = @At(value = "INVOKE",
17
            target = "Lnet/minecraft/network/FriendlyByteBuf;readNbt(Lio/netty/buffer/ByteBuf;Lnet/minecraft/nbt/NbtAccounter;)Lnet/minecraft/nbt/Tag;"))
18
    private static NbtAccounter liftTagLimit(NbtAccounter vanilla) {
19
        AntiPacketKick module = Modules.get(AntiPacketKick.class);
20
        return module != null && module.acceptsHugePackets() ? NbtAccounter.unlimitedHeap() : vanilla;
21
    }
22
}
23
GameRendererAccessorsrc/main/java/com/jellypudding/offlineclient/mixin/GameRendererAccessor.javaJava · 19 lines · 657 B
@Mixin(GameRenderer.class)
ModifiesGameRenderer
GameRendererAccessor.javaJava · 19 lines · 657 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.mojang.blaze3d.vertex.PoseStack;
4
import net.minecraft.client.renderer.GameRenderer;
5
import net.minecraft.client.renderer.state.level.CameraRenderState;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.gen.Invoker;
8
9
// The world to screen projection applies the same view bobbing the game uses.
10
@Mixin(GameRenderer.class)
11
public interface GameRendererAccessor {
12
13
    @Invoker("bobHurt")
14
    void offlineclient$bobHurt(CameraRenderState camera, PoseStack poseStack);
15
16
    @Invoker("bobView")
17
    void offlineclient$bobView(CameraRenderState camera, PoseStack poseStack);
18
}
19
GameRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/GameRendererMixin.javaJava · 48 lines · 2.2 KB
@Mixin(GameRenderer.class)
ModifiesGameRenderer
GameRendererMixin.javaJava · 48 lines · 2.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Blur;
4
import com.jellypudding.offlineclient.modules.render.ItemEsp;
5
import com.jellypudding.offlineclient.modules.render.NoHurtCam;
6
import com.jellypudding.offlineclient.util.Modules;
7
import com.mojang.blaze3d.vertex.PoseStack;
8
import net.minecraft.client.renderer.GameRenderer;
9
import net.minecraft.client.renderer.state.level.CameraRenderState;
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.ModifyArg;
14
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
15
16
@Mixin(GameRenderer.class)
17
public abstract class GameRendererMixin {
18
19
    // The whole hurt tilt is one call.
20
    @Inject(method = "bobHurt(Lnet/minecraft/client/renderer/state/level/CameraRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;)V",
21
        at = @At("HEAD"), cancellable = true)
22
    private void onBobHurt(CameraRenderState camera, PoseStack poseStack, CallbackInfo ci) {
23
        if (Modules.enabled(NoHurtCam.class)) {
24
            ci.cancel();
25
        }
26
    }
27
28
    // ItemESP holds the view still to keep its tracers from wobbling.
29
    @Inject(method = "bobView(Lnet/minecraft/client/renderer/state/level/CameraRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;)V",
30
        at = @At("HEAD"), cancellable = true)
31
    private void onBobView(CameraRenderState camera, PoseStack poseStack, CallbackInfo ci) {
32
        ItemEsp items = Modules.get(ItemEsp.class);
33
        if (items != null && items.holdsViewStill()) {
34
            ci.cancel();
35
        }
36
    }
37
38
    // The menu blur radius comes from the Blur module in place of the video option.
39
    @ModifyArg(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V",
40
        at = @At(value = "INVOKE",
41
            target = "Lnet/minecraft/client/renderer/GlobalSettingsUniform;update(IIDJLnet/minecraft/client/DeltaTracker;ILnet/minecraft/world/phys/Vec3;Z)V"),
42
        index = 5)
43
    private int onBlurRadius(int radius) {
44
        Blur blur = Modules.get(Blur.class);
45
        return blur == null ? radius : blur.radius(radius);
46
    }
47
}
48
GuiGraphicsExtractorMixinsrc/main/java/com/jellypudding/offlineclient/mixin/GuiGraphicsExtractorMixin.javaJava · 38 lines · 1.6 KB
@Mixin(GuiGraphicsExtractor.class)
GuiGraphicsExtractorMixin.javaJava · 38 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.BetterTooltips;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.gui.Font;
6
import net.minecraft.client.gui.GuiGraphicsExtractor;
7
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
8
import net.minecraft.world.item.ItemStack;
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.ModifyVariable;
13
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14
15
import java.util.List;
16
17
@Mixin(GuiGraphicsExtractor.class)
18
public class GuiGraphicsExtractorMixin {
19
20
    // The only place the stack behind a tooltip is still known.
21
    @Inject(
22
        method = "setTooltipForNextFrame(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V",
23
        at = @At("HEAD"))
24
    private void onSetTooltipForItem(Font font, ItemStack stack, int x, int y, CallbackInfo ci) {
25
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
26
        if (tooltips != null) {
27
            tooltips.setHovered(stack);
28
        }
29
    }
30
31
    // Some callers hand in an immutable list. The module builds a fresh one.
32
    @ModifyVariable(method = "setTooltipForNextFrameInternal", at = @At("HEAD"), index = 2)
33
    private List<ClientTooltipComponent> addPreview(List<ClientTooltipComponent> lines) {
34
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
35
        return tooltips == null ? lines : tooltips.decorate(lines);
36
    }
37
}
38
HudMixinsrc/main/java/com/jellypudding/offlineclient/mixin/HudMixin.javaJava · 135 lines · 5.6 KB
@Mixin(Hud.class)
ModifiesHud
HudMixin.javaJava · 135 lines · 5.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.Render2DEvent;
5
import com.jellypudding.offlineclient.modules.render.Blur;
6
import com.jellypudding.offlineclient.modules.render.ClearView;
7
import com.jellypudding.offlineclient.modules.render.ItemHighlight;
8
import com.jellypudding.offlineclient.util.Modules;
9
import net.minecraft.client.DeltaTracker;
10
import net.minecraft.client.gui.GuiGraphicsExtractor;
11
import net.minecraft.client.gui.Hud;
12
import net.minecraft.resources.Identifier;
13
import net.minecraft.world.entity.Entity;
14
import net.minecraft.world.entity.player.Player;
15
import net.minecraft.world.item.ItemStack;
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
22
import java.util.function.Predicate;
23
24
@Mixin(Hud.class)
25
public class HudMixin {
26
27
    // A blur still fading out after a screen closed goes under the HUD.
28
    @Inject(
29
        method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
30
        at = @At("HEAD"))
31
    private void onExtractHud(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
32
        Blur blur = Modules.get(Blur.class);
33
        if (blur != null && blur.fadingWithoutScreen()) {
34
            blur.blurHere(context);
35
        }
36
    }
37
38
    @Inject(
39
        method = "extractTabList(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/client/DeltaTracker;)V",
40
        at = @At("HEAD"))
41
    private void onRenderHud(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) {
42
        if (OfflineClient.MC.debugEntries.isOverlayVisible()) {
43
            return;
44
        }
45
        float tickDelta = tickCounter.getGameTimeDeltaPartialTick(true);
46
        OfflineClient.INSTANCE.getEventBus().post(new Render2DEvent(context, tickDelta));
47
    }
48
49
    @Inject(
50
        method = "extractTextureOverlay(Lnet/minecraft/client/gui/GuiGraphicsExtractor;Lnet/minecraft/resources/Identifier;F)V",
51
        at = @At("HEAD"),
52
        cancellable = true)
53
    private void onRenderOverlay(GuiGraphicsExtractor context, Identifier texture, float opacity, CallbackInfo ci) {
54
        if (texture == null) {
55
            return;
56
        }
57
        ClearView clearView = Modules.active(ClearView.class);
58
        if (clearView == null) {
59
            return;
60
        }
61
        String path = texture.getPath();
62
        if (("textures/misc/pumpkinblur.png".equals(path) && clearView.blocksPumpkin())
63
            || ("textures/misc/powder_snow_outline.png".equals(path) && clearView.blocksPowderSnow())) {
64
            ci.cancel();
65
        }
66
    }
67
68
    @Inject(method = "extractVignette", at = @At("HEAD"), cancellable = true)
69
    private void onRenderVignette(GuiGraphicsExtractor context, Entity entity, CallbackInfo ci) {
70
        ClearView clearView = Modules.active(ClearView.class);
71
        if (clearView != null && clearView.blocksVignette()) {
72
            ci.cancel();
73
        }
74
    }
75
76
    // The paint goes down before the item and sits under it.
77
    @Inject(method = "extractSlot(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IILnet/minecraft/client/DeltaTracker;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V",
78
        at = @At("HEAD"))
79
    private void onExtractSlot(GuiGraphicsExtractor context, int x, int y, DeltaTracker tickCounter,
80
                               Player player, ItemStack stack, int seed, CallbackInfo ci) {
81
        ItemHighlight highlight = Modules.get(ItemHighlight.class);
82
        if (highlight == null) {
83
            return;
84
        }
85
        int color = highlight.hotbarColorFor(stack);
86
        if (color != 0) {
87
            context.fill(x, y, x + 16, y + 16, color);
88
        }
89
    }
90
91
    // One HUD element each. Every one is skipped at the head of its own extract call.
92
    @Inject(method = "extractSpyglassOverlay", at = @At("HEAD"), cancellable = true)
93
    private void onSpyglass(CallbackInfo ci) {
94
        offlineclient$skip(ci, ClearView::blocksSpyglass);
95
    }
96
97
    @Inject(method = "extractBossOverlay", at = @At("HEAD"), cancellable = true)
98
    private void onBossBars(CallbackInfo ci) {
99
        offlineclient$skip(ci, ClearView::blocksBossBars);
100
    }
101
102
    @Inject(method = "extractScoreboardSidebar", at = @At("HEAD"), cancellable = true)
103
    private void onScoreboard(CallbackInfo ci) {
104
        offlineclient$skip(ci, ClearView::blocksScoreboard);
105
    }
106
107
    @Inject(method = "extractTitle", at = @At("HEAD"), cancellable = true)
108
    private void onTitle(CallbackInfo ci) {
109
        offlineclient$skip(ci, ClearView::blocksTitles);
110
    }
111
112
    @Inject(method = "extractSelectedItemName", at = @At("HEAD"), cancellable = true)
113
    private void onItemName(CallbackInfo ci) {
114
        offlineclient$skip(ci, ClearView::blocksItemNames);
115
    }
116
117
    @Inject(method = "extractEffects", at = @At("HEAD"), cancellable = true)
118
    private void onEffects(CallbackInfo ci) {
119
        offlineclient$skip(ci, ClearView::blocksEffectIcons);
120
    }
121
122
    @Inject(method = "extractCrosshair", at = @At("HEAD"), cancellable = true)
123
    private void onCrosshair(CallbackInfo ci) {
124
        offlineclient$skip(ci, ClearView::blocksCrosshair);
125
    }
126
127
    @Unique
128
    private static void offlineclient$skip(CallbackInfo ci, Predicate<ClearView> blocked) {
129
        ClearView clearView = Modules.active(ClearView.class);
130
        if (clearView != null && blocked.test(clearView)) {
131
            ci.cancel();
132
        }
133
    }
134
}
135
ItemContainerContentsMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ItemContainerContentsMixin.javaJava · 45 lines · 1.7 KB
@Mixin(ItemContainerContents.class)
ItemContainerContentsMixin.javaJava · 45 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.BetterTooltips;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.core.component.DataComponentGetter;
6
import net.minecraft.network.chat.Component;
7
import net.minecraft.world.item.Item;
8
import net.minecraft.world.item.ItemStackTemplate;
9
import net.minecraft.world.item.TooltipFlag;
10
import net.minecraft.world.item.component.ItemContainerContents;
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.injection.At;
15
import org.spongepowered.asm.mixin.injection.Inject;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
18
import java.util.List;
19
import java.util.Optional;
20
import java.util.function.Consumer;
21
22
@Mixin(ItemContainerContents.class)
23
public abstract class ItemContainerContentsMixin {
24
25
    @Shadow
26
    @Final
27
    private List<Optional<ItemStackTemplate>> items;
28
29
    // The vanilla item lines make way for the preview grid or the compact list.
30
    @Inject(method = "addToTooltip", at = @At("HEAD"), cancellable = true)
31
    private void onAddToTooltip(Item.TooltipContext context, Consumer<Component> out, TooltipFlag flag,
32
                                DataComponentGetter components, CallbackInfo ci) {
33
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
34
        if (tooltips == null) {
35
            return;
36
        }
37
        if (tooltips.skipsContainerLines()) {
38
            ci.cancel();
39
        } else if (tooltips.compactsContainerLines()) {
40
            tooltips.compactLines(items, out);
41
            ci.cancel();
42
        }
43
    }
44
}
45
ItemEntityRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ItemEntityRendererMixin.javaJava · 52 lines · 2.5 KB
@Mixin(ItemEntityRenderer.class)
ItemEntityRendererMixin.javaJava · 52 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ItemPhysics;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
6
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
7
import com.mojang.blaze3d.vertex.PoseStack;
8
import net.minecraft.client.renderer.SubmitNodeCollector;
9
import net.minecraft.client.renderer.entity.ItemEntityRenderer;
10
import net.minecraft.client.renderer.entity.state.ItemEntityRenderState;
11
import net.minecraft.client.renderer.state.level.CameraRenderState;
12
import org.joml.Quaternionfc;
13
import org.spongepowered.asm.mixin.Mixin;
14
import org.spongepowered.asm.mixin.Unique;
15
import org.spongepowered.asm.mixin.injection.At;
16
17
// ItemPhysics hooks. The bob and the spin are the only two poses a drop gets.
18
@Mixin(ItemEntityRenderer.class)
19
public abstract class ItemEntityRendererMixin {
20
21
    @Unique
22
    private static final String SUBMIT =
23
        "submit(Lnet/minecraft/client/renderer/entity/state/ItemEntityRenderState;"
24
            + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;"
25
            + "Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V";
26
27
    // The bob that lifts the drop off the ground.
28
    @WrapOperation(method = SUBMIT,
29
        at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V"))
30
    private void onLift(PoseStack target, float x, float y, float z, Operation<Void> original,
31
                        ItemEntityRenderState state, PoseStack poseStack,
32
                        SubmitNodeCollector collector, CameraRenderState camera) {
33
        ItemPhysics physics = Modules.active(ItemPhysics.class);
34
        original.call(target, x, physics == null ? y : physics.groundOffset(state), z);
35
    }
36
37
    // The spin the drop turns with.
38
    @WrapOperation(method = SUBMIT,
39
        at = @At(value = "INVOKE",
40
            target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionfc;)V"))
41
    private void onSpin(PoseStack target, Quaternionfc rotation, Operation<Void> original,
42
                        ItemEntityRenderState state, PoseStack poseStack,
43
                        SubmitNodeCollector collector, CameraRenderState camera) {
44
        ItemPhysics physics = Modules.active(ItemPhysics.class);
45
        if (physics == null) {
46
            original.call(target, rotation);
47
            return;
48
        }
49
        physics.lay(target, state);
50
    }
51
}
52
ItemFeatureRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ItemFeatureRendererMixin.javaJava · 27 lines · 1.2 KB
@Mixin(ItemFeatureRenderer.class)
ItemFeatureRendererMixin.javaJava · 27 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.client.renderer.feature.ItemFeatureRenderer;
7
import net.minecraft.client.renderer.item.ItemStackRenderState;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
11
@Mixin(ItemFeatureRenderer.class)
12
public abstract class ItemFeatureRendererMixin {
13
14
    // Every enchanted item in the world and in hand and in a screen asks here.
15
    @ModifyExpressionValue(method = "prepareFoilSubmit",
16
        at = @At(value = "INVOKE",
17
            target = "Lnet/minecraft/client/renderer/feature/ItemFeatureRenderer$Submit;foilType()"
18
                + "Lnet/minecraft/client/renderer/item/ItemStackRenderState$FoilType;"))
19
    private ItemStackRenderState.FoilType onFoilType(ItemStackRenderState.FoilType original) {
20
        NoRender noRender = Modules.get(NoRender.class);
21
        if (noRender != null && noRender.hidesGlint()) {
22
            return ItemStackRenderState.FoilType.NONE;
23
        }
24
        return original;
25
    }
26
}
27
ItemFrameRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ItemFrameRendererMixin.javaJava · 31 lines · 1.4 KB
@Mixin(ItemFrameRenderer.class)
ItemFrameRendererMixin.javaJava · 31 lines · 1.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.renderer.SubmitNodeCollector;
7
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
8
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
9
import net.minecraft.client.renderer.state.level.CameraRenderState;
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
15
@Mixin(ItemFrameRenderer.class)
16
public abstract class ItemFrameRendererMixin {
17
18
    @Inject(method = "submit(Lnet/minecraft/client/renderer/entity/state/ItemFrameRenderState;"
19
        + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;"
20
        + "Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V",
21
        at = @At("HEAD"),
22
        cancellable = true)
23
    private void onSubmit(ItemFrameRenderState state, PoseStack poseStack, SubmitNodeCollector collector,
24
                          CameraRenderState camera, CallbackInfo ci) {
25
        NoRender noRender = Modules.get(NoRender.class);
26
        if (noRender != null && noRender.hidesItemFrames()) {
27
            ci.cancel();
28
        }
29
    }
30
}
31
ItemInHandRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ItemInHandRendererMixin.javaJava · 158 lines · 7.6 KB
@Mixin(ItemInHandRenderer.class)
ModifiesItemInHandRenderer not in 26.3
ItemInHandRendererMixin.javaJava · 158 lines · 7.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Freecam;
4
import com.jellypudding.offlineclient.modules.render.HandView;
5
import com.jellypudding.offlineclient.modules.render.NoShieldOverlay;
6
import com.jellypudding.offlineclient.modules.render.Zoom;
7
import com.jellypudding.offlineclient.util.Modules;
8
9
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
10
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
11
import com.mojang.blaze3d.vertex.PoseStack;
12
import net.minecraft.client.player.AbstractClientPlayer;
13
import net.minecraft.client.player.LocalPlayer;
14
import net.minecraft.client.renderer.ItemInHandRenderer;
15
import net.minecraft.client.renderer.SubmitNodeCollector;
16
import net.minecraft.world.InteractionHand;
17
import net.minecraft.world.entity.HumanoidArm;
18
import net.minecraft.world.entity.player.Player;
19
import net.minecraft.world.item.ItemStack;
20
import net.minecraft.world.item.ItemUseAnimation;
21
import org.spongepowered.asm.mixin.Mixin;
22
import org.spongepowered.asm.mixin.Shadow;
23
import org.spongepowered.asm.mixin.Unique;
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
28
@Mixin(ItemInHandRenderer.class)
29
public abstract class ItemInHandRendererMixin {
30
31
    @Unique
32
    private static final String SUBMIT_HANDS = "submitHandsWithItems(FLcom/mojang/blaze3d/vertex/PoseStack;"
33
        + "Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/player/LocalPlayer;I)V";
34
35
    @Unique
36
    private static final String SUBMIT_ARM = "submitArmWithItem(Lnet/minecraft/client/player/AbstractClientPlayer;"
37
        + "FFLnet/minecraft/world/InteractionHand;FLnet/minecraft/world/item/ItemStack;F"
38
        + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V";
39
40
    @Shadow
41
    private ItemStack mainHandItem;
42
43
    @Shadow
44
    private ItemStack offHandItem;
45
46
    // The whole first person hand pass is skipped whilst a module hides it.
47
    @Inject(method = SUBMIT_HANDS, at = @At("HEAD"), cancellable = true)
48
    private void onSubmitHands(float partialTicks, PoseStack poseStack, SubmitNodeCollector collector,
49
                               LocalPlayer player, int light, CallbackInfo ci) {
50
        Freecam freecam = Modules.get(Freecam.class);
51
        Zoom zoom = Modules.get(Zoom.class);
52
        if ((freecam != null && freecam.hidesHand()) || (zoom != null && zoom.hidesHand())) {
53
            ci.cancel();
54
        }
55
    }
56
57
    // The swing progress both hands are drawn with.
58
    @ModifyExpressionValue(method = SUBMIT_HANDS,
59
        at = @At(value = "INVOKE",
60
            target = "Lnet/minecraft/client/player/LocalPlayer;getAttackAnim(F)F"))
61
    private float onSwingProgress(float original) {
62
        HandView handView = Modules.get(HandView.class);
63
        return handView == null ? original : handView.adjustSwing(original, mainHandItem, offHandItem);
64
    }
65
66
    // Just before a held item is drawn. The map paths have their own pose and are left alone.
67
    @Inject(method = SUBMIT_ARM,
68
        at = @At(value = "INVOKE",
69
            target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem("
70
                + "Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;"
71
                + "Lnet/minecraft/world/item/ItemDisplayContext;Lcom/mojang/blaze3d/vertex/PoseStack;"
72
                + "Lnet/minecraft/client/renderer/SubmitNodeCollector;I)V"))
73
    private void beforeItem(AbstractClientPlayer player, float partialTicks, float pitch,
74
                            InteractionHand hand, float swing, ItemStack stack, float equip,
75
                            PoseStack poseStack, SubmitNodeCollector collector, int light,
76
                            CallbackInfo ci) {
77
        HandView handView = Modules.get(HandView.class);
78
        if (handView != null) {
79
            handView.adjustItem(hand, poseStack);
80
        }
81
    }
82
83
    // Just before an empty arm is drawn.
84
    @Inject(method = SUBMIT_ARM,
85
        at = @At(value = "INVOKE",
86
            target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderPlayerArm("
87
                + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;"
88
                + "IFFLnet/minecraft/world/entity/HumanoidArm;)V"))
89
    private void beforeArm(AbstractClientPlayer player, float partialTicks, float pitch,
90
                           InteractionHand hand, float swing, ItemStack stack, float equip,
91
                           PoseStack poseStack, SubmitNodeCollector collector, int light,
92
                           CallbackInfo ci) {
93
        HandView handView = Modules.get(HandView.class);
94
        if (handView != null) {
95
            handView.adjustArm(poseStack);
96
        }
97
    }
98
99
    // Reached only whilst the item is in use. A shield in use is a raised shield.
100
    @Inject(method = SUBMIT_ARM,
101
        at = @At(value = "INVOKE",
102
            target = "Lnet/minecraft/world/item/ItemStack;getUseAnimation()Lnet/minecraft/world/item/ItemUseAnimation;",
103
            shift = At.Shift.AFTER))
104
    private void whileBlocking(AbstractClientPlayer player, float partialTicks, float pitch,
105
                               InteractionHand hand, float swing, ItemStack stack, float equip,
106
                               PoseStack poseStack, SubmitNodeCollector collector, int light,
107
                               CallbackInfo ci) {
108
        offlineclient$lowerShield(stack, poseStack, true);
109
    }
110
111
    // Reached for a held item that is not in use.
112
    @Inject(method = SUBMIT_ARM,
113
        at = @At(value = "INVOKE",
114
            target = "Lnet/minecraft/world/item/ItemStack;getSwingAnimation()Lnet/minecraft/world/item/component/SwingAnimation;"))
115
    private void whileResting(AbstractClientPlayer player, float partialTicks, float pitch,
116
                              InteractionHand hand, float swing, ItemStack stack, float equip,
117
                              PoseStack poseStack, SubmitNodeCollector collector, int light,
118
                              CallbackInfo ci) {
119
        offlineclient$lowerShield(stack, poseStack, false);
120
    }
121
122
    @Unique
123
    private static void offlineclient$lowerShield(ItemStack stack, PoseStack poseStack, boolean blocking) {
124
        if (stack.getUseAnimation() != ItemUseAnimation.BLOCK) {
125
            return;
126
        }
127
        NoShieldOverlay overlay = Modules.get(NoShieldOverlay.class);
128
        if (overlay != null) {
129
            overlay.lowerShield(poseStack, blocking);
130
        }
131
    }
132
133
    // A new item rises into view unless the swap is being skipped.
134
    @ModifyReturnValue(method = "shouldInstantlyReplaceVisibleItem", at = @At("RETURN"))
135
    private boolean onShouldReplaceInstantly(boolean original) {
136
        HandView handView = Modules.get(HandView.class);
137
        return original || (handView != null && handView.skipsSwap());
138
    }
139
140
    // The swap scale is cubed for the modern ease. One cubed is the old snap.
141
    @ModifyExpressionValue(method = "tick()V",
142
        at = @At(value = "INVOKE",
143
            target = "Lnet/minecraft/client/player/LocalPlayer;getItemSwapScale(F)F"))
144
    private float onSwapScale(float original) {
145
        HandView handView = Modules.get(HandView.class);
146
        return handView != null && handView.usesOldAnimations() ? 1f : original;
147
    }
148
149
    @Inject(method = "applyEatTransform", at = @At("HEAD"), cancellable = true)
150
    private void onEatTransform(PoseStack poseStack, float partialTicks, HumanoidArm arm,
151
                                ItemStack stack, Player player, CallbackInfo ci) {
152
        HandView handView = Modules.get(HandView.class);
153
        if (handView != null && handView.hidesEating()) {
154
            ci.cancel();
155
        }
156
    }
157
}
158
KeyboardHandlerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/KeyboardHandlerMixin.javaJava · 26 lines · 997 B
@Mixin(KeyboardHandler.class)
KeyboardHandlerMixin.javaJava · 26 lines · 997 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.KeyPressEvent;
5
import net.minecraft.client.KeyboardHandler;
6
import net.minecraft.client.input.KeyEvent;
7
import org.lwjgl.glfw.GLFW;
8
import org.spongepowered.asm.mixin.Mixin;
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
13
@Mixin(KeyboardHandler.class)
14
public class KeyboardHandlerMixin {
15
16
    @Inject(method = "keyPress(JILnet/minecraft/client/input/KeyEvent;)V", at = @At("HEAD"))
17
    private void onKeyPress(long windowHandle, int action, KeyEvent event, CallbackInfo ci) {
18
        // An unbound keybind holds this same value.
19
        if (event.key() == GLFW.GLFW_KEY_UNKNOWN) {
20
            return;
21
        }
22
        OfflineClient.INSTANCE.getEventBus()
23
            .post(new KeyPressEvent(event.key(), action));
24
    }
25
}
26
LevelExtractorMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LevelExtractorMixin.javaJava · 58 lines · 2.6 KB
@Mixin(LevelExtractor.class)
LevelExtractorMixin.javaJava · 58 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.modules.render.NoRender;
5
import com.jellypudding.offlineclient.modules.render.PopChams;
6
import com.jellypudding.offlineclient.util.Modules;
7
import net.minecraft.client.Camera;
8
import net.minecraft.client.DeltaTracker;
9
import net.minecraft.client.renderer.culling.Frustum;
10
import net.minecraft.client.renderer.extract.LevelExtractor;
11
import net.minecraft.client.renderer.state.level.LevelRenderState;
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
@Mixin(LevelExtractor.class)
20
public class LevelExtractorMixin {
21
22
    @Shadow
23
    @Final
24
    private LevelRenderState levelRenderState;
25
26
    @Inject(
27
        method = "extractVisibleEntities(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/culling/Frustum;Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/client/renderer/state/level/LevelRenderState;)V",
28
        at = @At("TAIL"))
29
    private void onExtractVisibleEntities(Camera camera, Frustum frustum, DeltaTracker deltaTracker,
30
                                          LevelRenderState level, CallbackInfo ci) {
31
        PopChams popChams = Modules.active(PopChams.class);
32
        if (popChams != null) {
33
            popChams.addGhosts(level, deltaTracker.getGameTimeDeltaPartialTick(false));
34
        }
35
    }
36
37
    // The cloud colour is worked out here and read by the cloud renderer after.
38
    @Inject(method = "extract(Lnet/minecraft/client/DeltaTracker;Lnet/minecraft/client/Camera;F)V",
39
        at = @At("TAIL"))
40
    private void onExtract(DeltaTracker deltaTracker, Camera camera, float partialTicks,
41
                           CallbackInfo ci) {
42
        Ambience ambience = Modules.get(Ambience.class);
43
        if (ambience != null && ambience.paintsClouds()) {
44
            levelRenderState.cloudColor = ambience.cloudColor();
45
        }
46
    }
47
48
    @Inject(
49
        method = "extractBlockDestroyAnimation(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/state/level/LevelRenderState;)V",
50
        at = @At("HEAD"), cancellable = true)
51
    private void onExtractBlockDestroyAnimation(Camera camera, LevelRenderState level, CallbackInfo ci) {
52
        NoRender noRender = Modules.get(NoRender.class);
53
        if (noRender != null && noRender.hidesBlockCracks()) {
54
            ci.cancel();
55
        }
56
    }
57
}
58
LevelMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LevelMixin.javaJava · 30 lines · 1.1 KB
@Mixin(Level.class)
ModifiesLevel
LevelMixin.javaJava · 30 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Weather;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.level.Level;
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
11
@Mixin(Level.class)
12
public class LevelMixin {
13
14
    @Inject(method = "getRainLevel(F)F", at = @At("HEAD"), cancellable = true)
15
    private void onGetRainLevel(float delta, CallbackInfoReturnable<Float> cir) {
16
        Weather weather = Modules.active(Weather.class);
17
        if (weather != null) {
18
            cir.setReturnValue(weather.rainLevel());
19
        }
20
    }
21
22
    @Inject(method = "getThunderLevel(F)F", at = @At("HEAD"), cancellable = true)
23
    private void onGetThunderLevel(float delta, CallbackInfoReturnable<Float> cir) {
24
        Weather weather = Modules.active(Weather.class);
25
        if (weather != null) {
26
            cir.setReturnValue(weather.thunderLevel());
27
        }
28
    }
29
}
30
LevelRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LevelRendererMixin.javaJava · 56 lines · 2.8 KB
@Mixin(LevelRenderer.class)
LevelRendererMixin.javaJava · 56 lines · 2.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.Render3DEvent;
5
import com.jellypudding.offlineclient.modules.render.BlockSelection;
6
import com.jellypudding.offlineclient.render.DrawBatch;
7
import com.jellypudding.offlineclient.util.Modules;
8
import com.mojang.blaze3d.buffers.GpuBufferSlice;
9
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import net.minecraft.client.DeltaTracker;
12
import net.minecraft.client.renderer.LevelRenderer;
13
import net.minecraft.client.renderer.SubmitNodeCollector;
14
import net.minecraft.client.renderer.state.level.CameraRenderState;
15
import net.minecraft.client.renderer.state.level.LevelRenderState;
16
import org.joml.Matrix4fc;
17
import org.joml.Vector4f;
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
23
@Mixin(LevelRenderer.class)
24
public class LevelRendererMixin {
25
26
    @Inject(
27
        method = "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",
28
        at = @At("RETURN"))
29
    private void onRender(GraphicsResourceAllocator allocator, DeltaTracker tickCounter,
30
                          boolean renderBlockOutline, CameraRenderState cameraState,
31
                          Matrix4fc positionMatrix, GpuBufferSlice gpuBufferSlice,
32
                          Vector4f vector4f, boolean shouldRenderSky, CallbackInfo ci) {
33
        PoseStack poseStack = new PoseStack();
34
        poseStack.mulPose(positionMatrix);
35
        float partialTicks = tickCounter.getGameTimeDeltaPartialTick(false);
36
        DrawBatch batch = new DrawBatch(poseStack);
37
        try {
38
            OfflineClient.INSTANCE.getEventBus().post(new Render3DEvent(batch, partialTicks));
39
        } finally {
40
            // The native buffer is freed even when a handler throws.
41
            batch.draw();
42
        }
43
    }
44
45
    // BlockSelection draws its own outline in place of the vanilla one.
46
    @Inject(
47
        method = "submitBlockOutline(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/LevelRenderState;)V",
48
        at = @At("HEAD"), cancellable = true)
49
    private void onSubmitBlockOutline(PoseStack poseStack, SubmitNodeCollector collector,
50
                                      LevelRenderState state, CallbackInfo ci) {
51
        if (Modules.enabled(BlockSelection.class)) {
52
            ci.cancel();
53
        }
54
    }
55
}
56
LightmapMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LightmapMixin.javaJava · 38 lines · 1.3 KB
@Mixin(Lightmap.class)
ModifiesLightmap
LightmapMixin.javaJava · 38 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.XRay;
4
import com.mojang.blaze3d.systems.RenderSystem;
5
import com.mojang.blaze3d.textures.GpuTexture;
6
import net.minecraft.client.renderer.Lightmap;
7
import net.minecraft.client.renderer.state.LightmapRenderState;
8
import org.joml.Vector4f;
9
import org.spongepowered.asm.mixin.Final;
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.Shadow;
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
16
@Mixin(Lightmap.class)
17
public abstract class LightmapMixin {
18
19
    @Shadow
20
    @Final
21
    private GpuTexture texture;
22
23
    // The vanilla lightmap comes back on its own the next time it updates.
24
    @Inject(
25
        method = "render(Lnet/minecraft/client/renderer/state/LightmapRenderState;)V",
26
        at = @At("HEAD"),
27
        cancellable = true)
28
    private void onRender(LightmapRenderState state, CallbackInfo ci) {
29
        XRay xray = XRay.get();
30
        if (xray == null || !xray.isEnabled()) {
31
            return;
32
        }
33
        RenderSystem.getDevice().createCommandEncoder()
34
            .clearColorTexture(texture, new Vector4f(1f, 1f, 1f, 1f));
35
        ci.cancel();
36
    }
37
}
38
LightningBoltRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LightningBoltRendererMixin.javaJava · 39 lines · 1.5 KB
@Mixin(LightningBoltRenderer.class)
LightningBoltRendererMixin.javaJava · 39 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.entity.LightningBoltRenderer;
6
import net.minecraft.util.ARGB;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.ModifyVariable;
10
11
// Every bolt quad is drawn from the same three colour parts.
12
@Mixin(LightningBoltRenderer.class)
13
public abstract class LightningBoltRendererMixin {
14
15
    @ModifyVariable(method = "quad", at = @At("HEAD"), argsOnly = true, index = 7)
16
    private static float boltRed(float vanilla) {
17
        int colour = offlineclient$colour();
18
        return colour == 0 ? vanilla : ARGB.red(colour) / 255f;
19
    }
20
21
    @ModifyVariable(method = "quad", at = @At("HEAD"), argsOnly = true, index = 8)
22
    private static float boltGreen(float vanilla) {
23
        int colour = offlineclient$colour();
24
        return colour == 0 ? vanilla : ARGB.green(colour) / 255f;
25
    }
26
27
    @ModifyVariable(method = "quad", at = @At("HEAD"), argsOnly = true, index = 9)
28
    private static float boltBlue(float vanilla) {
29
        int colour = offlineclient$colour();
30
        return colour == 0 ? vanilla : ARGB.blue(colour) / 255f;
31
    }
32
33
    // Zero when nothing is being recoloured.
34
    private static int offlineclient$colour() {
35
        Ambience ambience = Modules.get(Ambience.class);
36
        return ambience == null || !ambience.paintsLightning() ? 0 : ambience.lightningColor();
37
    }
38
}
39
LivingEntityMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LivingEntityMixin.javaJava · 119 lines · 5.3 KB
@Mixin(LivingEntity.class)
ModifiesLivingEntity
LivingEntityMixin.javaJava · 119 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.AutoWasp;
5
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
6
import com.jellypudding.offlineclient.modules.movement.Slippy;
7
import com.jellypudding.offlineclient.modules.movement.Sprint;
8
import com.jellypudding.offlineclient.modules.render.ClearView;
9
import com.jellypudding.offlineclient.modules.render.HandView;
10
import com.jellypudding.offlineclient.util.Modules;
11
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
12
import net.minecraft.client.player.LocalPlayer;
13
import net.minecraft.core.component.DataComponents;
14
import net.minecraft.world.item.ItemStack;
15
import net.minecraft.world.InteractionHand;
16
import net.minecraft.world.entity.LivingEntity;
17
import net.minecraft.world.level.block.Block;
18
import net.minecraft.world.phys.Vec3;
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.ModifyVariable;
23
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
24
25
@Mixin(LivingEntity.class)
26
public abstract class LivingEntityMixin {
27
28
    // The hand a hit swings. Only your own swings are changed.
29
    @ModifyVariable(method = "swing(Lnet/minecraft/world/InteractionHand;)V",
30
        at = @At("HEAD"), argsOnly = true)
31
    private InteractionHand onSwingHand(InteractionHand hand) {
32
        if ((Object) this != OfflineClient.MC.player) {
33
            return hand;
34
        }
35
        HandView handView = Modules.get(HandView.class);
36
        return handView == null ? hand : handView.swingHand(hand);
37
    }
38
39
    // Crumbs fly for food only. A drunk potion or a thrown egg keeps its particles.
40
    @Inject(method = "spawnItemParticles(Lnet/minecraft/world/item/ItemStack;I)V",
41
        at = @At("HEAD"), cancellable = true)
42
    private void onSpawnItemParticles(ItemStack stack, int count, CallbackInfo ci) {
43
        ClearView clearView = Modules.active(ClearView.class);
44
        if (clearView != null && clearView.blocksEatingCrumbs()
45
            && stack.getComponents().has(DataComponents.FOOD)) {
46
            ci.cancel();
47
        }
48
    }
49
50
    // The friction of the block underfoot sets the top speed. Slime is stickier than stone.
51
    @ModifyExpressionValue(method = "travelInAir(Lnet/minecraft/world/phys/Vec3;)V",
52
        at = @At(value = "INVOKE",
53
            target = "Lnet/minecraft/world/level/block/Block;getFriction()F"))
54
    private float onGroundFriction(float original) {
55
        if ((Object) this != OfflineClient.MC.player) {
56
            return original;
57
        }
58
        LivingEntity self = (LivingEntity) (Object) this;
59
        Block below = self.level().getBlockState(self.getBlockPosBelowThatAffectsMyMovement()).getBlock();
60
        float friction = original;
61
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
62
        if (noSlowdown != null) {
63
            friction = noSlowdown.groundFriction(below, friction);
64
        }
65
        Slippy slippy = Modules.get(Slippy.class);
66
        return slippy == null ? friction : slippy.groundFriction(below, friction);
67
    }
68
69
    // AutoWasp steers the glide straight at its target instead of along the look.
70
    @ModifyExpressionValue(method = "travelFallFlying(Lnet/minecraft/world/phys/Vec3;)V",
71
        at = @At(value = "INVOKE",
72
            target = "Lnet/minecraft/world/entity/LivingEntity;updateFallFlyingMovement(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;"))
73
    private Vec3 onGlideVelocity(Vec3 original) {
74
        if ((Object) this != OfflineClient.MC.player) {
75
            return original;
76
        }
77
        AutoWasp wasp = Modules.active(AutoWasp.class);
78
        if (wasp == null) {
79
            return original;
80
        }
81
        Vec3 steered = wasp.glideVelocity();
82
        return steered == null ? original : steered;
83
    }
84
85
    // The sprint jump pushes along the camera yaw. Rage sprint turns it along the keys.
86
    @ModifyExpressionValue(method = "jumpFromGround()V",
87
        at = @At(value = "INVOKE",
88
            target = "Lnet/minecraft/world/entity/LivingEntity;getYRot()F"))
89
    private float onJumpYaw(float original) {
90
        if ((Object) this != OfflineClient.MC.player) {
91
            return original;
92
        }
93
        Sprint sprint = Modules.get(Sprint.class);
94
        return sprint == null ? original : sprint.jumpYaw(original);
95
    }
96
97
    @ModifyExpressionValue(method = "jumpFromGround()V",
98
        at = @At(value = "INVOKE",
99
            target = "Lnet/minecraft/world/entity/LivingEntity;isSprinting()Z"))
100
    private boolean onJumpSprinting(boolean original) {
101
        if ((Object) this != OfflineClient.MC.player) {
102
            return original;
103
        }
104
        Sprint sprint = Modules.get(Sprint.class);
105
        return sprint == null ? original : sprint.jumpBoost(original, (LocalPlayer) (Object) this);
106
    }
107
108
    @ModifyExpressionValue(method = "getCurrentSwingDuration()I",
109
        at = @At(value = "INVOKE",
110
            target = "Lnet/minecraft/world/item/component/SwingAnimation;duration()I"))
111
    private int onSwingDuration(int original) {
112
        if ((Object) this != OfflineClient.MC.player) {
113
            return original;
114
        }
115
        HandView handView = Modules.get(HandView.class);
116
        return handView == null ? original : handView.swingDuration(original);
117
    }
118
}
119
LivingEntityRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LivingEntityRendererMixin.javaJava · 75 lines · 3.4 KB
@Mixin(LivingEntityRenderer.class)
LivingEntityRendererMixin.javaJava · 75 lines · 3.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.mixinterface.IRenderState;
4
import com.jellypudding.offlineclient.modules.render.Chams;
5
import com.jellypudding.offlineclient.render.EntityPipelines;
6
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
7
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
8
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
9
import net.minecraft.client.renderer.rendertype.RenderType;
10
import net.minecraft.client.renderer.rendertype.RenderTypes;
11
import net.minecraft.resources.Identifier;
12
import net.minecraft.util.ARGB;
13
import net.minecraft.world.entity.LivingEntity;
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.Inject;
18
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19
20
// Applies the flags Chams and TrueSight and PopChams put on a render state.
21
@Mixin(LivingEntityRenderer.class)
22
public abstract class LivingEntityRendererMixin {
23
24
    @Shadow
25
    public abstract Identifier getTextureLocation(LivingEntityRenderState state);
26
27
    @ModifyReturnValue(
28
        method = "isBodyVisible(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;)Z",
29
        at = @At("RETURN"))
30
    private boolean onIsBodyVisible(boolean original, LivingEntityRenderState state) {
31
        return original || ((IRenderState) state).offlineclient$isForceVisible();
32
    }
33
34
    @ModifyReturnValue(
35
        method = "getModelTint(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;)I",
36
        at = @At("RETURN"))
37
    private int onGetModelTint(int original, LivingEntityRenderState state) {
38
        int tint = ((IRenderState) state).offlineclient$getTint();
39
        return tint == 0 ? original : ARGB.multiply(original, tint);
40
    }
41
42
    @ModifyReturnValue(
43
        method = "getRenderType(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;ZZZ)Lnet/minecraft/client/renderer/rendertype/RenderType;",
44
        at = @At("RETURN"))
45
    private RenderType onGetRenderType(RenderType original, LivingEntityRenderState state,
46
                                       boolean bodyVisible, boolean translucent, boolean glowing) {
47
        // Anything else is the outline pass or nothing at all.
48
        if (!bodyVisible && !translucent) {
49
            return original;
50
        }
51
        IRenderState extra = (IRenderState) state;
52
        Identifier texture = extra.offlineclient$isFlat() ? Chams.BLANK : getTextureLocation(state);
53
        if (extra.offlineclient$isChams()) {
54
            return EntityPipelines.chams(texture);
55
        }
56
        int tint = extra.offlineclient$getTint();
57
        if (extra.offlineclient$isFlat() || (tint != 0 && ARGB.alpha(tint) < 255 && !translucent)) {
58
            return RenderTypes.entityTranslucent(texture);
59
        }
60
        return original;
61
    }
62
63
    // Chams grows or shrinks players after vanilla has set their size.
64
    @Inject(
65
        method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V",
66
        at = @At("TAIL"))
67
    private void onExtractLivingState(LivingEntity entity, LivingEntityRenderState state, float partialTicks,
68
                                      CallbackInfo ci) {
69
        Chams chams = Chams.get();
70
        if (chams != null) {
71
            state.scale *= chams.scaleFor(entity);
72
        }
73
    }
74
}
75
LocalPlayerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/LocalPlayerMixin.javaJava · 410 lines · 16.4 KB
@Mixin(LocalPlayer.class)
ModifiesLocalPlayer
LocalPlayerMixin.javaJava · 410 lines · 16.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.AirStrafingSpeedEvent;
5
import com.jellypudding.offlineclient.event.events.KnockbackEvent;
6
import com.jellypudding.offlineclient.event.events.PostMotionEvent;
7
import com.jellypudding.offlineclient.event.events.PreMotionEvent;
8
import com.jellypudding.offlineclient.event.events.TickEvent;
9
import com.jellypudding.offlineclient.modules.combat.BowAimbot;
10
import com.jellypudding.offlineclient.modules.movement.AntiPush;
11
import com.jellypudding.offlineclient.modules.movement.Flight;
12
import com.jellypudding.offlineclient.modules.movement.HighJump;
13
import com.jellypudding.offlineclient.modules.movement.HoleSnap;
14
import com.jellypudding.offlineclient.modules.movement.NoKnockback;
15
import com.jellypudding.offlineclient.modules.movement.LongJump;
16
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
17
import com.jellypudding.offlineclient.modules.movement.EdgeGuard;
18
import com.jellypudding.offlineclient.modules.movement.Sprint;
19
import com.jellypudding.offlineclient.modules.movement.Step;
20
import com.jellypudding.offlineclient.modules.movement.VehicleFly;
21
import com.jellypudding.offlineclient.modules.player.AutoDrop;
22
import com.jellypudding.offlineclient.modules.player.AutoEat;
23
import com.jellypudding.offlineclient.modules.player.AutoGap;
24
import com.jellypudding.offlineclient.modules.player.FastBreak;
25
import com.jellypudding.offlineclient.modules.player.PortalMenus;
26
import com.jellypudding.offlineclient.modules.player.Reach;
27
import com.jellypudding.offlineclient.modules.render.AntiBlind;
28
import com.jellypudding.offlineclient.modules.world.AirPlace;
29
import com.jellypudding.offlineclient.util.Modules;
30
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
31
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
32
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
33
import com.mojang.authlib.GameProfile;
34
import net.minecraft.client.gui.screens.Screen;
35
import net.minecraft.client.multiplayer.ClientLevel;
36
import net.minecraft.client.player.AbstractClientPlayer;
37
import net.minecraft.client.player.LocalPlayer;
38
import net.minecraft.core.BlockPos;
39
import net.minecraft.core.Holder;
40
import net.minecraft.world.effect.MobEffect;
41
import net.minecraft.world.effect.MobEffectInstance;
42
import net.minecraft.world.effect.MobEffects;
43
import net.minecraft.world.entity.PlayerRideableJumping;
44
import net.minecraft.world.entity.player.Abilities;
45
import net.minecraft.world.level.block.state.BlockState;
46
import net.minecraft.world.phys.Vec3;
47
import org.spongepowered.asm.mixin.Mixin;
48
import org.spongepowered.asm.mixin.Shadow;
49
import org.spongepowered.asm.mixin.Unique;
50
import org.spongepowered.asm.mixin.injection.At;
51
import org.spongepowered.asm.mixin.injection.Inject;
52
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
53
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
54
55
@Mixin(LocalPlayer.class)
56
public abstract class LocalPlayerMixin extends AbstractClientPlayer {
57
58
    // The throw key never gives away an item AutoDrop is guarding.
59
    @Inject(method = "drop(Z)Z", at = @At("HEAD"), cancellable = true)
60
    private void onDrop(boolean whole, CallbackInfoReturnable<Boolean> cir) {
61
        AutoDrop autoDrop = Modules.get(AutoDrop.class);
62
        if (autoDrop != null && autoDrop.guards(OfflineClient.MC.player.getMainHandItem())) {
63
            cir.setReturnValue(false);
64
        }
65
    }
66
67
    @Shadow
68
    public float portalEffectIntensity;
69
70
    @Shadow
71
    public float oPortalEffectIntensity;
72
73
    // Never called. The compiler only wants a constructor for the parent.
74
    private LocalPlayerMixin(ClientLevel level, GameProfile profile) {
75
        super(level, profile);
76
    }
77
78
    @Inject(method = "tick()V",
79
        at = @At(value = "INVOKE",
80
            target = "Lnet/minecraft/client/player/AbstractClientPlayer;tick()V",
81
            ordinal = 0))
82
    private void onTick(CallbackInfo ci) {
83
        OfflineClient.INSTANCE.getEventBus().post(TickEvent.INSTANCE);
84
    }
85
86
    // A mounted player never reaches sendPosition in this method.
87
    // Posting here on both sides of that branch keeps an aura working on a horse.
88
    @Inject(method = "tick()V",
89
        at = @At(value = "INVOKE",
90
            target = "Lnet/minecraft/client/player/LocalPlayer;isPassenger()Z"))
91
    private void onPreMotion(CallbackInfo ci) {
92
        OfflineClient.INSTANCE.getEventBus().post(PreMotionEvent.INSTANCE);
93
    }
94
95
    @Inject(method = "tick()V", at = @At("TAIL"))
96
    private void onPostMotion(CallbackInfo ci) {
97
        OfflineClient.INSTANCE.getEventBus().post(PostMotionEvent.INSTANCE);
98
    }
99
100
    // Vanilla closes any screen the moment the portal effect starts. With no
101
    // screen in sight that branch never runs.
102
    @ModifyExpressionValue(method = "handlePortalTransitionEffect(Z)V",
103
        at = @At(value = "INVOKE",
104
            target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;",
105
            ordinal = 0))
106
    private Screen hideScreenFromPortal(Screen original) {
107
        return Modules.active(PortalMenus.class) == null ? original : null;
108
    }
109
110
    @WrapOperation(method = "aiStep()V",
111
        at = @At(value = "INVOKE",
112
            target = "Lnet/minecraft/client/player/LocalPlayer;isSlowDueToUsingItem()Z",
113
            ordinal = 0))
114
    private boolean wrapAiStepItemUse(LocalPlayer instance, Operation<Boolean> original) {
115
        if (offlineclient$noSlowdown()) {
116
            return false;
117
        }
118
        return original.call(instance);
119
    }
120
121
    @WrapOperation(
122
        method = "modifyInput(Lnet/minecraft/world/phys/Vec2;)Lnet/minecraft/world/phys/Vec2;",
123
        at = @At(value = "INVOKE",
124
            target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z",
125
            ordinal = 0))
126
    private boolean wrapModifyInputItemUse(LocalPlayer instance, Operation<Boolean> original) {
127
        if (offlineclient$noSlowdown()) {
128
            return false;
129
        }
130
        return original.call(instance);
131
    }
132
133
    @Unique
134
    private static boolean offlineclient$noSlowdown() {
135
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
136
        if (noSlowdown != null && noSlowdown.skipsItems()) {
137
            return true;
138
        }
139
        BowAimbot bowAimbot = Modules.get(BowAimbot.class);
140
        if (bowAimbot != null && bowAimbot.suppressesSlowdown()) {
141
            return true;
142
        }
143
        AutoEat autoEat = Modules.get(AutoEat.class);
144
        if (autoEat != null && autoEat.suppressesSlowdown()) {
145
            return true;
146
        }
147
        AutoGap autoGap = Modules.get(AutoGap.class);
148
        return autoGap != null && autoGap.suppressesSlowdown();
149
    }
150
151
    @Override
152
    protected float getFlyingSpeed() {
153
        AirStrafingSpeedEvent event = new AirStrafingSpeedEvent(super.getFlyingSpeed());
154
        OfflineClient.INSTANCE.getEventBus().post(event);
155
        return event.getSpeed();
156
    }
157
158
    @Override
159
    public void lerpMotion(Vec3 vec) {
160
        KnockbackEvent event = new KnockbackEvent(vec.x, vec.y, vec.z);
161
        OfflineClient.INSTANCE.getEventBus().post(event);
162
        super.lerpMotion(new Vec3(event.getX(), event.getY(), event.getZ()));
163
    }
164
165
    @Override
166
    protected float getJumpPower() {
167
        HighJump highJump = Modules.get(HighJump.class);
168
        return super.getJumpPower() + (highJump == null ? 0f : highJump.getAdditionalJumpMotion());
169
    }
170
171
    @Override
172
    public void jumpFromGround() {
173
        HoleSnap holeSnap = Modules.get(HoleSnap.class);
174
        if (holeSnap != null && holeSnap.cancelsJump()) {
175
            return;
176
        }
177
        super.jumpFromGround();
178
        LongJump longJump = Modules.get(LongJump.class);
179
        if (longJump != null) {
180
            longJump.onJump();
181
        }
182
        HighJump highJump = Modules.get(HighJump.class);
183
        if (highJump != null) {
184
            highJump.onJump();
185
        }
186
    }
187
188
    // Rage sprint answers the three vanilla sprint rules itself. Anything that
189
    // would normally refuse a sprint such as a wall or an item in use is ignored.
190
    @Inject(method = "canStartSprinting()Z", at = @At("HEAD"), cancellable = true)
191
    private void onCanStartSprinting(CallbackInfoReturnable<Boolean> cir) {
192
        Sprint sprint = Modules.get(Sprint.class);
193
        if (sprint != null && sprint.rage()) {
194
            cir.setReturnValue(!isSprinting() && sprint.rageWantsSprint((LocalPlayer) (Object) this));
195
        }
196
    }
197
198
    @Inject(method = "shouldStopRunSprinting()Z", at = @At("HEAD"), cancellable = true)
199
    private void onShouldStopRunSprinting(CallbackInfoReturnable<Boolean> cir) {
200
        Sprint sprint = Modules.get(Sprint.class);
201
        if (sprint != null && sprint.rage()) {
202
            cir.setReturnValue(!sprint.rageWantsSprint((LocalPlayer) (Object) this));
203
        }
204
    }
205
206
    @Inject(method = "shouldStopSwimSprinting()Z", at = @At("HEAD"), cancellable = true)
207
    private void onShouldStopSwimSprinting(CallbackInfoReturnable<Boolean> cir) {
208
        Sprint sprint = Modules.get(Sprint.class);
209
        if (sprint != null && sprint.rage()) {
210
            cir.setReturnValue(!sprint.rageWantsSprint((LocalPlayer) (Object) this));
211
        }
212
    }
213
214
    // The one place creative flight reads the fly speed for its push up
215
    // and down. Flight hands over its own vertical speed instead of scaling it.
216
    @WrapOperation(method = "aiStep()V",
217
        at = @At(value = "INVOKE",
218
            target = "Lnet/minecraft/world/entity/player/Abilities;getFlyingSpeed()F"))
219
    private float wrapVerticalFlySpeed(Abilities abilities, Operation<Float> original) {
220
        Flight flight = Modules.active(Flight.class);
221
        return flight == null ? original.call(abilities) : flight.verticalFlySpeed();
222
    }
223
224
    // Crowd pushing checks this on both sides of a collision. False here
225
    // blocks incoming pushes and leaves outgoing ones alone.
226
    @Override
227
    public boolean isPushable() {
228
        AntiPush antiPush = Modules.get(AntiPush.class);
229
        if (antiPush != null && antiPush.blocksEntities()) {
230
            return false;
231
        }
232
        return super.isPushable();
233
    }
234
235
    @Override
236
    public boolean isPushedByFluid() {
237
        AntiPush antiPush = Modules.get(AntiPush.class);
238
        if (antiPush != null && antiPush.blocksCurrents()) {
239
            return false;
240
        }
241
        return super.isPushedByFluid();
242
    }
243
244
    @Override
245
    public void onAboveBubbleColumn(boolean downwards, BlockPos pos) {
246
        AntiPush antiPush = Modules.get(AntiPush.class);
247
        if (antiPush != null && antiPush.blocksBubbleColumns()) {
248
            return;
249
        }
250
        super.onAboveBubbleColumn(downwards, pos);
251
    }
252
253
    @Override
254
    public void onInsideBubbleColumn(boolean downwards) {
255
        AntiPush antiPush = Modules.get(AntiPush.class);
256
        if (antiPush != null && antiPush.blocksBubbleColumns()) {
257
            return;
258
        }
259
        super.onInsideBubbleColumn(downwards);
260
    }
261
262
    // The client predicts mining five times slower in the air. FastBreak
263
    // fixes the server side by rewriting packets and can raise the rate outright.
264
    @Override
265
    public float getDestroySpeed(BlockState state) {
266
        float speed = super.getDestroySpeed(state);
267
        FastBreak fastBreak = Modules.get(FastBreak.class);
268
        return fastBreak == null ? speed : fastBreak.adjustSpeed(state, speed);
269
    }
270
271
    // Honey and soul sand slow through this factor alone.
272
    @Override
273
    protected float getBlockSpeedFactor() {
274
        float factor = super.getBlockSpeedFactor();
275
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
276
        if (factor >= 1 || noSlowdown == null) {
277
            return factor;
278
        }
279
        boolean skipped = noSlowdown.skipsBlockFriction(level().getBlockState(blockPosition()).getBlock())
280
            || noSlowdown.skipsBlockFriction(
281
                level().getBlockState(getBlockPosBelowThatAffectsMyMovement()).getBlock());
282
        return skipped ? 1 : factor;
283
    }
284
285
    // The sneak slowdown hangs off this. Crawling keeps its own pace.
286
    @Inject(method = "isMovingSlowly()Z", at = @At("HEAD"), cancellable = true)
287
    private void onIsMovingSlowly(CallbackInfoReturnable<Boolean> cir) {
288
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
289
        if (noSlowdown != null && noSlowdown.skipsSneaking()) {
290
            cir.setReturnValue(isVisuallyCrawling());
291
        }
292
    }
293
294
    @Override
295
    public float getSpeed() {
296
        float speed = super.getSpeed();
297
        MobEffectInstance slowness = getEffect(MobEffects.SLOWNESS);
298
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
299
        if (slowness == null || noSlowdown == null) {
300
            return speed;
301
        }
302
        return noSlowdown.withoutSlowness(speed, slowness.getAmplifier());
303
    }
304
305
    // A jumping mount takes the jump key to charge its leap. VehicleFly wants it to lift.
306
    @Inject(method = "jumpableVehicle()Lnet/minecraft/world/entity/PlayerRideableJumping;",
307
        at = @At("HEAD"), cancellable = true)
308
    private void onJumpableVehicle(CallbackInfoReturnable<PlayerRideableJumping> cir) {
309
        VehicleFly vehicleFly = Modules.get(VehicleFly.class);
310
        if (vehicleFly != null && vehicleFly.takesJumpKey()) {
311
            cir.setReturnValue(null);
312
        }
313
    }
314
315
    // The charge of a horse jump. One is a full power leap.
316
    @Inject(method = "getJumpRidingScale()F", at = @At("HEAD"), cancellable = true)
317
    private void onGetJumpRidingScale(CallbackInfoReturnable<Float> cir) {
318
        VehicleFly vehicleFly = Modules.get(VehicleFly.class);
319
        if (vehicleFly != null && vehicleFly.maxesJump()) {
320
            cir.setReturnValue(1f);
321
        }
322
    }
323
324
    // Vanilla shoves the player out of any block they stand inside.
325
    @Inject(method = "moveTowardsClosestSpace(DD)V", at = @At("HEAD"), cancellable = true)
326
    private void onMoveTowardsClosestSpace(double x, double z, CallbackInfo ci) {
327
        NoKnockback noKnockback = Modules.get(NoKnockback.class);
328
        if (noKnockback != null && noKnockback.blocksBlockPush()) {
329
            ci.cancel();
330
        }
331
    }
332
333
    @Override
334
    public float maxUpStep() {
335
        float vanilla = super.maxUpStep();
336
        Step step = Modules.get(Step.class);
337
        return step == null ? vanilla : step.adjustStepHeight(vanilla);
338
    }
339
340
    @Override
341
    protected boolean isStayingOnGroundSurface() {
342
        if (super.isStayingOnGroundSurface()) {
343
            return true;
344
        }
345
        EdgeGuard edgeGuard = Modules.get(EdgeGuard.class);
346
        return edgeGuard != null && edgeGuard.shouldGuard();
347
    }
348
349
    @Override
350
    public double blockInteractionRange() {
351
        double range = super.blockInteractionRange();
352
        Reach reach = Modules.get(Reach.class);
353
        if (reach != null) {
354
            range = reach.adjustBlockRange(range);
355
        }
356
        // A block placed in the air has to be reachable to build onto.
357
        AirPlace airPlace = Modules.active(AirPlace.class);
358
        return airPlace == null ? range : Math.max(range, airPlace.getRange());
359
    }
360
361
    @Override
362
    public double entityInteractionRange() {
363
        double vanilla = super.entityInteractionRange();
364
        Reach reach = Modules.get(Reach.class);
365
        return reach == null ? vanilla : reach.adjustEntityRange(vanilla);
366
    }
367
368
    @Override
369
    public boolean hasEffect(Holder<MobEffect> effect) {
370
        if (blocked(effect)) {
371
            return false;
372
        }
373
        return super.hasEffect(effect);
374
    }
375
376
    // The pulsing darkness dimming and the nausea spin read this instead of hasEffect.
377
    @Override
378
    public float getEffectBlendFactor(Holder<MobEffect> effect, float partialTicks) {
379
        if (blocked(effect)) {
380
            return 0;
381
        }
382
        return super.getEffectBlendFactor(effect, partialTicks);
383
    }
384
385
    @Unique
386
    private static boolean blocked(Holder<MobEffect> effect) {
387
        AntiBlind antiBlind = Modules.active(AntiBlind.class);
388
        if (antiBlind == null) {
389
            return false;
390
        }
391
        if (effect == MobEffects.BLINDNESS) {
392
            return antiBlind.blocksBlindness();
393
        }
394
        if (effect == MobEffects.DARKNESS) {
395
            return antiBlind.blocksDarkness();
396
        }
397
        return effect == MobEffects.NAUSEA && antiBlind.blocksNausea();
398
    }
399
400
    // The renderer reads the intensity a tick behind. Clearing it here is enough.
401
    @Inject(method = "tick()V", at = @At("TAIL"))
402
    private void onTickEnd(CallbackInfo ci) {
403
        AntiBlind antiBlind = Modules.active(AntiBlind.class);
404
        if (antiBlind != null && antiBlind.blocksPortal()) {
405
            portalEffectIntensity = 0;
406
            oPortalEffectIntensity = 0;
407
        }
408
    }
409
}
410
MapRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MapRendererMixin.javaJava · 40 lines · 1.9 KB
@Mixin(MapRenderer.class)
ModifiesMapRenderer
MapRendererMixin.javaJava · 40 lines · 1.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.renderer.MapRenderer;
7
import net.minecraft.client.renderer.SubmitNodeCollector;
8
import net.minecraft.client.renderer.state.MapRenderState;
9
import net.minecraft.world.level.saveddata.maps.MapId;
10
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
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
16
@Mixin(MapRenderer.class)
17
public abstract class MapRendererMixin {
18
19
    @Inject(method = "render(Lnet/minecraft/client/renderer/state/MapRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;"
20
        + "Lnet/minecraft/client/renderer/SubmitNodeCollector;ZI)V", at = @At("HEAD"), cancellable = true)
21
    private void onRender(MapRenderState state, PoseStack poseStack, SubmitNodeCollector collector,
22
                          boolean flat, int light, CallbackInfo ci) {
23
        NoRender noRender = Modules.get(NoRender.class);
24
        if (noRender != null && noRender.hidesMapContents()) {
25
            ci.cancel();
26
        }
27
    }
28
29
    // The markers are gathered into the state and dropped again before anything reads them.
30
    @Inject(method = "extractRenderState(Lnet/minecraft/world/level/saveddata/maps/MapId;"
31
        + "Lnet/minecraft/world/level/saveddata/maps/MapItemSavedData;Lnet/minecraft/client/renderer/state/MapRenderState;)V",
32
        at = @At("TAIL"))
33
    private void onExtractRenderState(MapId id, MapItemSavedData data, MapRenderState state, CallbackInfo ci) {
34
        NoRender noRender = Modules.get(NoRender.class);
35
        if (noRender != null && noRender.hidesMapMarkers()) {
36
            state.decorations.clear();
37
        }
38
    }
39
}
40
MinecraftMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MinecraftMixin.javaJava · 173 lines · 6.9 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
MinecraftMixin.javaJava · 173 lines · 6.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.ClientTickEvent;
5
import com.jellypudding.offlineclient.event.events.LeftClickEvent;
6
import com.jellypudding.offlineclient.event.events.RightClickEvent;
7
import com.jellypudding.offlineclient.modules.player.InventoryTweaks;
8
import com.jellypudding.offlineclient.modules.player.Multitask;
9
import com.jellypudding.offlineclient.modules.render.Esp;
10
import com.jellypudding.offlineclient.modules.render.Freecam;
11
import com.jellypudding.offlineclient.util.BlockMiner;
12
import com.jellypudding.offlineclient.util.Modules;
13
14
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
15
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
16
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
17
import net.minecraft.client.Minecraft;
18
import net.minecraft.client.player.LocalPlayer;
19
import net.minecraft.world.entity.Entity;
20
import org.spongepowered.asm.mixin.Mixin;
21
import org.spongepowered.asm.mixin.Shadow;
22
import org.spongepowered.asm.mixin.Unique;
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
28
@Mixin(Minecraft.class)
29
public abstract class MinecraftMixin {
30
31
    @Shadow
32
    private void handleKeybinds() {
33
    }
34
35
    @Shadow
36
    private void continueAttack(boolean holding) {
37
    }
38
39
    // Whether the attack key was down when the tick skipped its mining call.
40
    @Unique
41
    private boolean offlineclient$breaking;
42
43
    @Unique
44
    private static boolean offlineclient$frameInput() {
45
        InventoryTweaks tweaks = Modules.get(InventoryTweaks.class);
46
        return tweaks != null && tweaks.frameInput();
47
    }
48
49
    // The keys are read once a frame instead. The tick call goes.
50
    @WrapOperation(method = "tick()V",
51
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;handleKeybinds()V"))
52
    private void tickKeybinds(Minecraft instance, Operation<Void> original) {
53
        if (offlineclient$frameInput()) {
54
            continueAttack(offlineclient$breaking);
55
            offlineclient$breaking = false;
56
            return;
57
        }
58
        original.call(instance);
59
    }
60
61
    // Mining still runs once a tick even whilst the keys are read every frame.
62
    @WrapOperation(method = "handleKeybinds()V",
63
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;continueAttack(Z)V"))
64
    private void frameAttack(Minecraft instance, boolean holding, Operation<Void> original) {
65
        if (offlineclient$frameInput()) {
66
            offlineclient$breaking = holding;
67
            return;
68
        }
69
        original.call(instance, holding);
70
    }
71
72
    @Inject(method = "renderFrame(Z)V",
73
        at = @At(value = "INVOKE",
74
            target = "Lnet/minecraft/client/renderer/LevelRenderer;endFrame()V",
75
            shift = At.Shift.AFTER))
76
    private void onRenderFrame(boolean advanceTime, CallbackInfo ci) {
77
        if (OfflineClient.MC.player != null && offlineclient$frameInput()) {
78
            handleKeybinds();
79
        }
80
    }
81
82
    // Fires once per game tick even in menus. Modules that need a loaded
83
    // world use TickEvent instead.
84
    @Inject(method = "tick()V", at = @At("TAIL"))
85
    private void onTick(CallbackInfo ci) {
86
        OfflineClient.INSTANCE.getEventBus().post(ClientTickEvent.INSTANCE);
87
    }
88
89
    // Vanilla aborts any block mining every tick the attack key is up and
90
    // restarts it on whatever the crosshair hits.
91
    @Inject(method = "continueAttack(Z)V", at = @At("HEAD"), cancellable = true)
92
    private void onContinueAttack(boolean holding, CallbackInfo ci) {
93
        if (BlockMiner.isActive() || offlineclient$freecamBlocks()) {
94
            ci.cancel();
95
        }
96
    }
97
98
    @Inject(method = "startAttack()Z", at = @At("HEAD"), cancellable = true)
99
    private void onStartAttack(CallbackInfoReturnable<Boolean> cir) {
100
        if (OfflineClient.INSTANCE.getEventBus().post(new LeftClickEvent()).isCancelled()
101
            || offlineclient$freecamBlocks()) {
102
            cir.setReturnValue(false);
103
        }
104
    }
105
106
    @Unique
107
    private static boolean offlineclient$freecamBlocks() {
108
        Freecam freecam = Modules.get(Freecam.class);
109
        return freecam != null && freecam.blocksClicks();
110
    }
111
112
    @Inject(method = "startUseItem()V", at = @At("HEAD"), cancellable = true)
113
    private void onStartUseItem(CallbackInfo ci) {
114
        if (OfflineClient.INSTANCE.getEventBus().post(new RightClickEvent()).isCancelled()) {
115
            ci.cancel();
116
        }
117
    }
118
119
    @Inject(method = "shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z",
120
        at = @At("HEAD"),
121
        cancellable = true)
122
    private void onShouldEntityAppearGlowing(Entity entity, CallbackInfoReturnable<Boolean> cir) {
123
        Esp esp = Modules.get(Esp.class);
124
        if (esp != null && esp.shouldGlow(entity)) {
125
            cir.setReturnValue(true);
126
        }
127
    }
128
129
    // Vanilla swallows a right click for as long as a block is being broken.
130
    @ModifyExpressionValue(method = "startUseItem()V",
131
        at = @At(value = "INVOKE",
132
            target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;isDestroying()Z"))
133
    private boolean allowUseWhileMining(boolean original) {
134
        Multitask multitask = offlineclient$module();
135
        return original && (multitask == null || !multitask.usesWhileMining());
136
    }
137
138
    // Vanilla stops block breaking for as long as an item is in use.
139
    @ModifyExpressionValue(method = "continueAttack(Z)V",
140
        at = @At(value = "INVOKE",
141
            target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z"))
142
    private boolean allowMineWhileUsing(boolean original) {
143
        Multitask multitask = offlineclient$module();
144
        return original && (multitask == null || !multitask.minesWhileUsing());
145
    }
146
147
    // Vanilla takes a whole branch whilst an item is in use where clicks
148
    // are drained instead of acted on. That branch also releases the item.
149
    @WrapOperation(method = "handleKeybinds()V",
150
        at = @At(value = "INVOKE",
151
            target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z", ordinal = 0))
152
    private boolean allowAttackWhileUsing(LocalPlayer player, Operation<Boolean> original) {
153
        boolean using = original.call(player);
154
        Multitask multitask = offlineclient$module();
155
        if (!using || multitask == null || !multitask.attacksWhileUsing()) {
156
            return using;
157
        }
158
        Minecraft mc = OfflineClient.MC;
159
        if (!mc.options.keyUse.isDown()) {
160
            mc.gameMode.releaseUsingItem(player);
161
        }
162
        while (mc.options.keyUse.consumeClick()) {
163
            // A queued right click would restart the use this tick.
164
        }
165
        return false;
166
    }
167
168
    @Unique
169
    private static Multitask offlineclient$module() {
170
        return Modules.get(Multitask.class);
171
    }
172
}
173
MobEffectInstanceMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MobEffectInstanceMixin.javaJava · 23 lines · 916 B
@Mixin(MobEffectInstance.class)
MobEffectInstanceMixin.javaJava · 23 lines · 916 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.player.PotionSaver;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.effect.MobEffectInstance;
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.CallbackInfo;
10
11
@Mixin(MobEffectInstance.class)
12
public abstract class MobEffectInstanceMixin {
13
14
    // The client counts every effect down here once a tick.
15
    @Inject(method = "tickDownDuration()V", at = @At("HEAD"), cancellable = true)
16
    private void onTickDownDuration(CallbackInfo ci) {
17
        PotionSaver potionSaver = Modules.get(PotionSaver.class);
18
        if (potionSaver != null && potionSaver.shouldFreeze((MobEffectInstance) (Object) this)) {
19
            ci.cancel();
20
        }
21
    }
22
}
23
MobMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MobMixin.javaJava · 23 lines · 889 B
@Mixin(Mob.class)
ModifiesMob
MobMixin.javaJava · 23 lines · 889 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.movement.VehicleFly;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.world.entity.Mob;
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
11
@Mixin(Mob.class)
12
public abstract class MobMixin {
13
14
    // The client only steers a saddled mount. VehicleFly can pretend they all are.
15
    @Inject(method = "isSaddled()Z", at = @At("HEAD"), cancellable = true)
16
    private void onIsSaddled(CallbackInfoReturnable<Boolean> cir) {
17
        VehicleFly vehicleFly = Modules.get(VehicleFly.class);
18
        if (vehicleFly != null && vehicleFly.spoofsSaddle()) {
19
            cir.setReturnValue(true);
20
        }
21
    }
22
}
23
ModelBlockRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ModelBlockRendererMixin.javaJava · 76 lines · 3.7 KB
@Mixin(ModelBlockRenderer.class)
ModelBlockRendererMixin.javaJava · 76 lines · 3.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.XRay;
4
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
5
import com.mojang.blaze3d.vertex.QuadInstance;
6
import net.minecraft.client.renderer.block.BlockAndTintGetter;
7
import net.minecraft.client.renderer.block.BlockQuadOutput;
8
import net.minecraft.client.renderer.block.ModelBlockRenderer;
9
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
10
import net.minecraft.client.resources.model.geometry.BakedQuad;
11
import net.minecraft.core.BlockPos;
12
import net.minecraft.core.Direction;
13
import net.minecraft.util.ARGB;
14
import net.minecraft.world.level.block.state.BlockState;
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
22
import java.util.List;
23
24
// XRay hooks for solid blocks. Chunk meshing runs on worker threads and
25
// the per block alpha lives in a thread local on the XRay module.
26
@Mixin(ModelBlockRenderer.class)
27
public abstract class ModelBlockRendererMixin {
28
29
    @Shadow
30
    @Final
31
    private QuadInstance quadInstance;
32
33
    @Inject(
34
        method = {
35
            "tesselateFlat(Lnet/minecraft/client/renderer/block/BlockQuadOutput;FFFLjava/util/List;Lnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V",
36
            "tesselateAmbientOcclusion(Lnet/minecraft/client/renderer/block/BlockQuadOutput;FFFLjava/util/List;Lnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V"
37
        },
38
        at = @At("HEAD"),
39
        cancellable = true)
40
    private void onTesselate(BlockQuadOutput output, float x, float y, float z,
41
                             List<BlockStateModelPart> parts, BlockAndTintGetter level,
42
                             BlockState state, BlockPos pos, CallbackInfo ci) {
43
        int alpha = XRay.meshAlphaFor(level, state, pos);
44
        XRay.setMeshAlpha(alpha);
45
        if (alpha == 0) {
46
            ci.cancel();
47
        }
48
    }
49
50
    @Inject(
51
        method = "putQuadWithTint(Lnet/minecraft/client/renderer/block/BlockQuadOutput;FFFLnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/client/resources/model/geometry/BakedQuad;)V",
52
        at = @At("HEAD"))
53
    private void onPutQuad(BlockQuadOutput output, float x, float y, float z, BlockAndTintGetter level,
54
                           BlockState state, BlockPos pos, BakedQuad quad, CallbackInfo ci) {
55
        if (XRay.meshingTranslucent()) {
56
            quadInstance.multiplyColor(ARGB.color(XRay.meshAlpha(), 255, 255, 255));
57
        }
58
    }
59
60
    // Wanted blocks draw every face that does not touch another wanted block.
61
    @ModifyReturnValue(
62
        method = "shouldRenderFace(Lnet/minecraft/client/renderer/block/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;Lnet/minecraft/core/BlockPos;)Z",
63
        at = @At("RETURN"))
64
    private boolean onShouldRenderFace(boolean original, BlockAndTintGetter level, BlockState state,
65
                                       Direction direction, BlockPos neighborPos) {
66
        if (original) {
67
            return true;
68
        }
69
        XRay xray = XRay.get();
70
        if (xray == null || !xray.isEnabled() || !xray.isVisible(state.getBlock())) {
71
            return false;
72
        }
73
        return !xray.isVisible(level.getBlockState(neighborPos).getBlock());
74
    }
75
}
76
MouseHandlerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MouseHandlerMixin.javaJava · 97 lines · 4.1 KB
@Mixin(MouseHandler.class)
ModifiesMouseHandler
MouseHandlerMixin.javaJava · 97 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.MouseScrollEvent;
5
import com.jellypudding.offlineclient.modules.combat.AimAssist;
6
import com.jellypudding.offlineclient.modules.player.GUIMove;
7
import com.jellypudding.offlineclient.modules.player.MiddleClickExtra;
8
import com.jellypudding.offlineclient.modules.render.FreeLook;
9
import com.jellypudding.offlineclient.modules.render.Freecam;
10
import com.jellypudding.offlineclient.util.Modules;
11
12
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
13
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
14
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
15
import net.minecraft.client.MouseHandler;
16
import net.minecraft.client.gui.screens.Screen;
17
import net.minecraft.client.input.MouseButtonInfo;
18
import net.minecraft.client.player.LocalPlayer;
19
import org.lwjgl.glfw.GLFW;
20
import org.spongepowered.asm.mixin.Mixin;
21
import org.spongepowered.asm.mixin.Unique;
22
import org.spongepowered.asm.mixin.injection.At;
23
import org.spongepowered.asm.mixin.injection.Inject;
24
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25
26
@Mixin(MouseHandler.class)
27
public abstract class MouseHandlerMixin {
28
29
    @WrapOperation(method = "turnPlayer(D)V",
30
        at = @At(value = "INVOKE",
31
            target = "Lnet/minecraft/client/player/LocalPlayer;turn(DD)V"))
32
    private void wrapTurn(LocalPlayer player, double deltaYaw, double deltaPitch,
33
                          Operation<Void> original) {
34
        Freecam freecam = Modules.get(Freecam.class);
35
        if (freecam != null && freecam.movesCamera()) {
36
            freecam.turn(deltaYaw, deltaPitch);
37
            return;
38
        }
39
        FreeLook freeLook = Modules.get(FreeLook.class);
40
        if (freeLook != null && freeLook.stealsMouse()) {
41
            freeLook.turn(deltaYaw, deltaPitch);
42
            return;
43
        }
44
        AimAssist aim = Modules.get(AimAssist.class);
45
        double scale = aim == null ? 1 : aim.mouseScale();
46
        original.call(player, deltaYaw * scale, deltaPitch * scale);
47
    }
48
49
    @Inject(method = "onButton(JLnet/minecraft/client/input/MouseButtonInfo;I)V",
50
        at = @At("HEAD"),
51
        cancellable = true)
52
    private void onButton(long window, MouseButtonInfo info, int action, CallbackInfo ci) {
53
        // The pointer is hidden and off its last spot.
54
        if (offlineclient$turning()) {
55
            ci.cancel();
56
            return;
57
        }
58
        if (info.button() == GLFW.GLFW_MOUSE_BUTTON_MIDDLE && action == GLFW.GLFW_PRESS) {
59
            MiddleClickExtra extra = Modules.get(MiddleClickExtra.class);
60
            if (extra != null) {
61
                extra.onMiddleClick();
62
            }
63
        }
64
    }
65
66
    // Modules may take the wheel before it reaches the hotbar.
67
    @Inject(method = "onScroll(JDD)V", at = @At("HEAD"), cancellable = true)
68
    private void onScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
69
        if (OfflineClient.MC.gui.screen() != null || vertical == 0) {
70
            return;
71
        }
72
        if (OfflineClient.INSTANCE.getEventBus().post(new MouseScrollEvent(vertical)).isCancelled()) {
73
            ci.cancel();
74
        }
75
    }
76
77
    @Unique
78
    private static boolean offlineclient$turning() {
79
        GUIMove guiMove = Modules.get(GUIMove.class);
80
        return guiMove != null && guiMove.isTurning();
81
    }
82
83
    @ModifyExpressionValue(method = "handleAccumulatedMovement()V",
84
        at = @At(value = "INVOKE",
85
            target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;"))
86
    private Screen hideScreenWhileTurning(Screen original) {
87
        return offlineclient$turning() ? null : original;
88
    }
89
90
    // Vanilla only turns the player whilst the mouse is grabbed.
91
    @ModifyExpressionValue(method = "handleAccumulatedMovement()V",
92
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MouseHandler;isMouseGrabbed()Z"))
93
    private boolean turnWhileScreenOpen(boolean original) {
94
        return original || offlineclient$turning();
95
    }
96
}
97
MultiPlayerGameModeAccessorsrc/main/java/com/jellypudding/offlineclient/mixin/MultiPlayerGameModeAccessor.javaJava · 18 lines · 557 B
@Mixin(MultiPlayerGameMode.class)
MultiPlayerGameModeAccessor.javaJava · 18 lines · 557 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
4
import net.minecraft.core.BlockPos;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.gen.Accessor;
7
8
// The client's own fractional break progress that the server never echoes back.
9
@Mixin(MultiPlayerGameMode.class)
10
public interface MultiPlayerGameModeAccessor {
11
12
    @Accessor("destroyProgress")
13
    float offlineclient$destroyProgress();
14
15
    @Accessor("destroyBlockPos")
16
    BlockPos offlineclient$destroyBlockPos();
17
}
18
MultiPlayerGameModeMixinsrc/main/java/com/jellypudding/offlineclient/mixin/MultiPlayerGameModeMixin.javaJava · 208 lines · 9.9 KB
@Mixin(MultiPlayerGameMode.class)
MultiPlayerGameModeMixin.javaJava · 208 lines · 9.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.events.AttackEntityEvent;
5
import com.jellypudding.offlineclient.event.events.BlockBreakEvent;
6
import com.jellypudding.offlineclient.modules.movement.ElytraBoost;
7
import com.jellypudding.offlineclient.modules.player.AutoDrop;
8
import com.jellypudding.offlineclient.modules.player.FastBreak;
9
import com.jellypudding.offlineclient.modules.player.NoInteract;
10
import com.jellypudding.offlineclient.modules.world.NoGhostBlocks;
11
import com.jellypudding.offlineclient.util.Modules;
12
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
13
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
14
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
15
import net.minecraft.client.Minecraft;
16
import net.minecraft.client.multiplayer.ClientLevel;
17
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
18
import net.minecraft.client.multiplayer.prediction.PredictiveAction;
19
import net.minecraft.client.player.LocalPlayer;
20
import net.minecraft.core.BlockPos;
21
import net.minecraft.core.Direction;
22
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
23
import net.minecraft.world.InteractionHand;
24
import net.minecraft.world.InteractionResult;
25
import net.minecraft.world.entity.decoration.ItemFrame;
26
import net.minecraft.world.inventory.ContainerInput;
27
import net.minecraft.world.level.block.DecoratedPotBlock;
28
import net.minecraft.world.entity.Entity;
29
import net.minecraft.world.entity.player.Player;
30
import net.minecraft.world.level.Level;
31
import net.minecraft.world.level.block.state.BlockState;
32
import net.minecraft.world.phys.BlockHitResult;
33
import net.minecraft.world.phys.EntityHitResult;
34
import org.spongepowered.asm.mixin.Final;
35
import org.spongepowered.asm.mixin.Mixin;
36
import org.spongepowered.asm.mixin.Shadow;
37
import org.spongepowered.asm.mixin.Unique;
38
import org.spongepowered.asm.mixin.injection.At;
39
import org.spongepowered.asm.mixin.injection.Inject;
40
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
41
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
42
43
@Mixin(MultiPlayerGameMode.class)
44
public abstract class MultiPlayerGameModeMixin {
45
46
    @Shadow
47
    @Final
48
    private Minecraft minecraft;
49
50
    @Shadow
51
    private float destroyProgress;
52
53
    @Shadow
54
    private BlockPos destroyBlockPos;
55
56
    @Shadow
57
    public abstract boolean destroyBlock(BlockPos pos);
58
59
    @Shadow
60
    protected abstract void startPrediction(ClientLevel level, PredictiveAction action);
61
62
    @Inject(
63
        method = "attack(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;)V",
64
        at = @At("HEAD"))
65
    private void onAttack(Player player, Entity target, CallbackInfo ci) {
66
        if (player != minecraft.player) {
67
            return;
68
        }
69
        OfflineClient.INSTANCE.getEventBus().post(new AttackEntityEvent(target));
70
    }
71
72
    @Inject(
73
        method = "startDestroyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z",
74
        at = @At("HEAD"), cancellable = true)
75
    private void onStartDestroyBlock(BlockPos pos, Direction direction,
76
                                     CallbackInfoReturnable<Boolean> cir) {
77
        OfflineClient.INSTANCE.getEventBus().post(new BlockBreakEvent(pos));
78
        FastBreak fastBreak = Modules.active(FastBreak.class);
79
        if (fastBreak == null || minecraft.level == null) {
80
            return;
81
        }
82
        BlockState state = minecraft.level.getBlockState(pos);
83
        if (fastBreak.guardsClick(state, pos)) {
84
            cir.setReturnValue(true);
85
        } else if (fastBreak.instamines(state, pos)) {
86
            offlineclient$breakOutright(pos, direction);
87
            cir.setReturnValue(true);
88
        }
89
    }
90
91
    // The server finishes a block on the tick after a start and stop pair
92
    // when one tick of progress passes half way.
93
    @Unique
94
    private void offlineclient$breakOutright(BlockPos pos, Direction direction) {
95
        destroyBlock(pos);
96
        startPrediction(minecraft.level, sequence -> new ServerboundPlayerActionPacket(
97
            ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, direction, sequence));
98
        startPrediction(minecraft.level, sequence -> new ServerboundPlayerActionPacket(
99
            ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, direction, sequence));
100
    }
101
102
    // The progress one held tick adds. FastBreak rounds it up to a finish early.
103
    @ModifyExpressionValue(
104
        method = "continueDestroyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z",
105
        at = @At(value = "INVOKE",
106
            target = "Lnet/minecraft/world/level/block/state/BlockState;getDestroyProgress(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)F"))
107
    private float adjustProgress(float original) {
108
        FastBreak fastBreak = Modules.active(FastBreak.class);
109
        if (fastBreak == null || destroyBlockPos == null || minecraft.level == null) {
110
            return original;
111
        }
112
        BlockState state = minecraft.level.getBlockState(destroyBlockPos);
113
        return fastBreak.adjustProgress(state, destroyProgress, original);
114
    }
115
116
    @Inject(
117
        method = "continueDestroyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z",
118
        at = @At("HEAD"))
119
    private void onContinueDestroyBlock(BlockPos pos, Direction direction,
120
                                        CallbackInfoReturnable<Boolean> cir) {
121
        OfflineClient.INSTANCE.getEventBus().post(new BlockBreakEvent(pos));
122
    }
123
124
    // ElytraBoost swaps a real rocket for a client side one before it is spent.
125
    @Inject(
126
        method = "useItem(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/InteractionResult;",
127
        at = @At("HEAD"), cancellable = true)
128
    private void onUseItem(Player player, InteractionHand hand,
129
                           CallbackInfoReturnable<InteractionResult> cir) {
130
        ElytraBoost boost = Modules.active(ElytraBoost.class);
131
        if (player == minecraft.player && boost != null
132
            && boost.interceptsUse(player.getItemInHand(hand))) {
133
            cir.setReturnValue(InteractionResult.PASS);
134
        }
135
    }
136
137
    // NoInteract drops every block right click made with a chosen hand.
138
    @Inject(
139
        method = "useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;",
140
        at = @At("HEAD"), cancellable = true)
141
    private void onUseItemOn(LocalPlayer player, InteractionHand hand, BlockHitResult hit,
142
                             CallbackInfoReturnable<InteractionResult> cir) {
143
        NoInteract noInteract = Modules.active(NoInteract.class);
144
        if (noInteract != null && noInteract.blocksUseWith(hand)) {
145
            cir.setReturnValue(InteractionResult.FAIL);
146
            return;
147
        }
148
        AutoDrop autoDrop = Modules.get(AutoDrop.class);
149
        if (autoDrop == null || !autoDrop.guardsFrames() || minecraft.level == null) {
150
            return;
151
        }
152
        if (minecraft.level.getBlockState(hit.getBlockPos()).getBlock() instanceof DecoratedPotBlock
153
            && autoDrop.guards(player.getItemInHand(hand))) {
154
            cir.setReturnValue(InteractionResult.FAIL);
155
        }
156
    }
157
158
    // NoInteract drops every entity right click made with a chosen hand.
159
    @Inject(
160
        method = "interact(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/EntityHitResult;Lnet/minecraft/world/InteractionHand;)Lnet/minecraft/world/InteractionResult;",
161
        at = @At("HEAD"), cancellable = true)
162
    private void onInteract(Player player, Entity target, EntityHitResult hit, InteractionHand hand,
163
                            CallbackInfoReturnable<InteractionResult> cir) {
164
        NoInteract noInteract = Modules.active(NoInteract.class);
165
        if (noInteract != null && noInteract.blocksEntityUseWith(hand)) {
166
            cir.setReturnValue(InteractionResult.FAIL);
167
            return;
168
        }
169
        AutoDrop autoDrop = Modules.get(AutoDrop.class);
170
        if (autoDrop != null && autoDrop.guardsFrames() && target instanceof ItemFrame
171
            && autoDrop.guards(player.getItemInHand(hand))) {
172
            cir.setReturnValue(InteractionResult.FAIL);
173
        }
174
    }
175
176
    // A guarded item is never thrown from a slot and never posted into a pot.
177
    @Inject(
178
        method = "handleContainerInput(IIILnet/minecraft/world/inventory/ContainerInput;Lnet/minecraft/world/entity/player/Player;)V",
179
        at = @At("HEAD"), cancellable = true)
180
    private void onContainerInput(int containerId, int slot, int button, ContainerInput kind,
181
                                  Player player, CallbackInfo ci) {
182
        if (kind != ContainerInput.THROW || slot < 0) {
183
            return;
184
        }
185
        AutoDrop autoDrop = Modules.get(AutoDrop.class);
186
        if (autoDrop == null || slot >= player.containerMenu.slots.size()) {
187
            return;
188
        }
189
        if (autoDrop.guards(player.containerMenu.getSlot(slot).getItem())) {
190
            ci.cancel();
191
        }
192
    }
193
194
    // Vanilla clears the block on screen the instant it asks the server to
195
    // break it. The break effects only play when that write lands.
196
    @WrapOperation(method = "destroyBlock(Lnet/minecraft/core/BlockPos;)Z",
197
        at = @At(value = "INVOKE",
198
            target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
199
    private boolean holdBreak(Level level, BlockPos pos, BlockState state, int flags,
200
                              Operation<Boolean> original) {
201
        NoGhostBlocks noGhostBlocks = Modules.get(NoGhostBlocks.class);
202
        if (noGhostBlocks != null && noGhostBlocks.holdsBreaks()) {
203
            return false;
204
        }
205
        return original.call(level, pos, state, flags);
206
    }
207
}
208
NoInteractMixinsrc/main/java/com/jellypudding/offlineclient/mixin/NoInteractMixin.javaJava · 77 lines · 2.9 KB
@Mixin(Minecraft.class)
ModifiesMinecraft
NoInteractMixin.javaJava · 77 lines · 2.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.player.AutoEat;
5
import com.jellypudding.offlineclient.modules.player.AutoGap;
6
import com.jellypudding.offlineclient.modules.player.NoInteract;
7
import com.jellypudding.offlineclient.util.Modules;
8
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
9
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.core.BlockPos;
12
import net.minecraft.core.Direction;
13
import net.minecraft.world.phys.BlockHitResult;
14
import net.minecraft.world.phys.HitResult;
15
import org.spongepowered.asm.mixin.Mixin;
16
import org.spongepowered.asm.mixin.Unique;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
21
22
@Mixin(Minecraft.class)
23
public abstract class NoInteractMixin {
24
25
    @Inject(method = "startAttack()Z", at = @At("HEAD"), cancellable = true)
26
    private void onStartAttack(CallbackInfoReturnable<Boolean> cir) {
27
        NoInteract noInteract = Modules.active(NoInteract.class);
28
        if (noInteract == null) {
29
            return;
30
        }
31
        if (OfflineClient.MC.hitResult != null && noInteract.blocksAttack(OfflineClient.MC.hitResult)) {
32
            cir.setReturnValue(false);
33
        }
34
    }
35
36
    // Blanks the crosshair target whilst a feeder holds the use key. A chest
37
    // or villager then cannot swallow the bite. Restored after.
38
    @WrapMethod(method = "startUseItem()V")
39
    private void wrapStartUseItem(Operation<Void> original) {
40
        Minecraft mc = OfflineClient.MC;
41
        HitResult real = mc.hitResult;
42
        if (real == null || real.getType() == HitResult.Type.MISS || !offlineclient$feeding()) {
43
            original.call();
44
            return;
45
        }
46
        mc.hitResult = BlockHitResult.miss(real.getLocation(), Direction.UP,
47
            BlockPos.containing(real.getLocation()));
48
        try {
49
            original.call();
50
        } finally {
51
            mc.hitResult = real;
52
        }
53
    }
54
55
    @Unique
56
    private static boolean offlineclient$feeding() {
57
        AutoEat autoEat = Modules.get(AutoEat.class);
58
        if (autoEat != null && autoEat.isBusy()) {
59
            return true;
60
        }
61
        AutoGap autoGap = Modules.get(AutoGap.class);
62
        return autoGap != null && autoGap.isBusy();
63
    }
64
65
    @Inject(method = "continueAttack(Z)V", at = @At("HEAD"), cancellable = true)
66
    private void onContinueAttack(boolean holding, CallbackInfo ci) {
67
        NoInteract noInteract = Modules.active(NoInteract.class);
68
        if (noInteract == null) {
69
            return;
70
        }
71
        if (OfflineClient.MC.hitResult instanceof BlockHitResult hit
72
            && noInteract.blocksMining(hit.getBlockPos())) {
73
            ci.cancel();
74
        }
75
    }
76
}
77
OptionInstanceMixinsrc/main/java/com/jellypudding/offlineclient/mixin/OptionInstanceMixin.javaJava · 34 lines · 897 B
@Mixin(OptionInstance.class)
OptionInstanceMixin.javaJava · 34 lines · 897 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.mixinterface.ISimpleOption;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.OptionInstance;
6
import org.spongepowered.asm.mixin.Final;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.Shadow;
9
10
import java.util.Objects;
11
12
@Mixin(OptionInstance.class)
13
public class OptionInstanceMixin<T> implements ISimpleOption<T> {
14
15
    @Shadow
16
    T value;
17
18
    @Shadow
19
    @Final
20
    private OptionInstance.ValueUpdateListener<? super T> onValueUpdate;
21
22
    @Override
23
    public void offlineclient$forceSetValue(T newValue) {
24
        if (!Minecraft.getInstance().isRunning()) {
25
            value = newValue;
26
            return;
27
        }
28
        if (!Objects.equals(value, newValue)) {
29
            value = newValue;
30
            onValueUpdate.valueChanged(value);
31
        }
32
    }
33
}
34
PacketBundlerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PacketBundlerMixin.javaJava · 19 lines · 827 B
@Mixin(targets = "net.minecraft.network.protocol.BundlerInfo$1$1")
PacketBundlerMixin.javaJava · 19 lines · 827 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.AntiPacketKick;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.injection.At;
8
9
// A bundle carrying more than four thousand packets is refused by vanilla.
10
@Mixin(targets = "net.minecraft.network.protocol.BundlerInfo$1$1")
11
public abstract class PacketBundlerMixin {
12
13
    @ModifyExpressionValue(method = "addPacket", at = @At(value = "CONSTANT", args = "intValue=4096"))
14
    private int liftBundleLimit(int vanilla) {
15
        AntiPacketKick module = Modules.get(AntiPacketKick.class);
16
        return module != null && module.acceptsHugePackets() ? Integer.MAX_VALUE : vanilla;
17
    }
18
}
19
ParticleEngineMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ParticleEngineMixin.javaJava · 36 lines · 1.6 KB
@Mixin(ParticleEngine.class)
ParticleEngineMixin.javaJava · 36 lines · 1.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ClearView;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.particle.Particle;
6
import net.minecraft.client.particle.ParticleEngine;
7
import net.minecraft.core.particles.ParticleOptions;
8
import org.spongepowered.asm.mixin.Mixin;
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
14
@Mixin(ParticleEngine.class)
15
public class ParticleEngineMixin {
16
17
    @Inject(method = "add(Lnet/minecraft/client/particle/Particle;)V", at = @At("HEAD"), cancellable = true)
18
    private void onAdd(Particle particle, CallbackInfo ci) {
19
        ClearView clearView = Modules.active(ClearView.class);
20
        if (clearView != null && clearView.blocksAllParticles()) {
21
            ci.cancel();
22
        }
23
    }
24
25
    // Particles made from options carry their type. The add hook above catches the rest.
26
    @Inject(method = "createParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)"
27
        + "Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
28
    private void onCreateParticle(ParticleOptions options, double x, double y, double z,
29
                                  double dx, double dy, double dz, CallbackInfoReturnable<Particle> cir) {
30
        ClearView clearView = Modules.active(ClearView.class);
31
        if (clearView != null && clearView.blocksParticle(options.getType())) {
32
            cir.setReturnValue(null);
33
        }
34
    }
35
}
36
PickMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PickMixin.javaJava · 80 lines · 3.6 KB
@Mixin(LocalPlayer.class)
ModifiesLocalPlayer
PickMixin.javaJava · 80 lines · 3.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.player.LiquidInteract;
4
import com.jellypudding.offlineclient.modules.player.NoMiningTrace;
5
import com.jellypudding.offlineclient.modules.render.Freecam;
6
import com.jellypudding.offlineclient.util.Modules;
7
import net.minecraft.client.player.LocalPlayer;
8
import net.minecraft.world.entity.Entity;
9
import net.minecraft.world.level.ClipContext;
10
import net.minecraft.world.phys.BlockHitResult;
11
import net.minecraft.world.phys.EntityHitResult;
12
import net.minecraft.world.phys.HitResult;
13
import net.minecraft.world.phys.Vec3;
14
import org.spongepowered.asm.mixin.Mixin;
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.CallbackInfoReturnable;
19
20
@Mixin(LocalPlayer.class)
21
public abstract class PickMixin {
22
23
    // Freecam swaps the whole ray for one cast from the camera.
24
    @Inject(method = "raycastHitResult(FLnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/HitResult;",
25
        at = @At("HEAD"),
26
        cancellable = true)
27
    private void onPickFromCamera(float partialTicks, Entity camera,
28
                                  CallbackInfoReturnable<HitResult> cir) {
29
        Freecam freecam = Modules.active(Freecam.class);
30
        if (freecam != null && freecam.interactsFromCamera()) {
31
            cir.setReturnValue(freecam.pick((LocalPlayer) (Object) this, partialTicks));
32
        }
33
    }
34
35
    // Runs once per frame after vanilla has picked.
36
    @Inject(method = "raycastHitResult(FLnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/HitResult;",
37
        at = @At("RETURN"),
38
        cancellable = true)
39
    private void onRaycastHitResult(float partialTicks, Entity camera,
40
                                    CallbackInfoReturnable<HitResult> cir) {
41
        LocalPlayer player = (LocalPlayer) (Object) this;
42
        HitResult result = cir.getReturnValue();
43
        if (result == null || camera == null) {
44
            return;
45
        }
46
47
        NoMiningTrace noTrace = Modules.get(NoMiningTrace.class);
48
        if (noTrace != null && result instanceof EntityHitResult hit && noTrace.ignores(hit.getEntity())) {
49
            result = offlineclient$clip(player, camera, partialTicks, ClipContext.Fluid.NONE);
50
            cir.setReturnValue(result);
51
        }
52
53
        LiquidInteract liquid = Modules.active(LiquidInteract.class);
54
        if (liquid == null) {
55
            return;
56
        }
57
        BlockHitResult fluidHit = offlineclient$clip(player, camera, partialTicks,
58
            liquid.includesFlowing() ? ClipContext.Fluid.ANY : ClipContext.Fluid.SOURCE_ONLY);
59
        if (fluidHit.getType() == HitResult.Type.MISS) {
60
            return;
61
        }
62
        Vec3 eye = camera.getEyePosition(partialTicks);
63
        if (result.getType() == HitResult.Type.MISS
64
            || fluidHit.getLocation().distanceToSqr(eye) < result.getLocation().distanceToSqr(eye)) {
65
            cir.setReturnValue(fluidHit);
66
        }
67
    }
68
69
    // The same block ray vanilla casts with a chosen liquid rule.
70
    @Unique
71
    private static BlockHitResult offlineclient$clip(LocalPlayer player, Entity camera,
72
                                                     float partialTicks, ClipContext.Fluid fluid) {
73
        double range = player.blockInteractionRange();
74
        Vec3 eye = camera.getEyePosition(partialTicks);
75
        Vec3 end = eye.add(camera.getViewVector(partialTicks).scale(range));
76
        return player.level().clip(
77
            new ClipContext(eye, end, ClipContext.Block.OUTLINE, fluid, player));
78
    }
79
}
80
PlayerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PlayerMixin.javaJava · 90 lines · 4.1 KB
@Mixin(Player.class)
ModifiesPlayer
PlayerMixin.javaJava · 90 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.EdgeGuard;
5
import com.jellypudding.offlineclient.modules.movement.NoClip;
6
import com.jellypudding.offlineclient.modules.movement.Sprint;
7
import com.jellypudding.offlineclient.modules.world.Scaffold;
8
import com.jellypudding.offlineclient.util.Modules;
9
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
10
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
11
import net.minecraft.world.entity.MoverType;
12
import net.minecraft.world.entity.player.Player;
13
import net.minecraft.world.phys.Vec3;
14
import org.spongepowered.asm.mixin.Mixin;
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.CallbackInfoReturnable;
19
20
@Mixin(Player.class)
21
public abstract class PlayerMixin {
22
23
    // Vanilla sneaking clamps the player to the edge. Scaffold has already
24
    // placed the block below whilst it is building downward.
25
    @Inject(
26
        method = "maybeBackOffFromEdge(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/MoverType;)Lnet/minecraft/world/phys/Vec3;",
27
        at = @At("HEAD"),
28
        cancellable = true)
29
    private void onMaybeBackOffFromEdge(Vec3 movement, MoverType type,
30
                                        CallbackInfoReturnable<Vec3> cir) {
31
        Scaffold scaffold = Modules.get(Scaffold.class);
32
        if (scaffold != null && scaffold.isDescending()) {
33
            cir.setReturnValue(movement);
34
        }
35
    }
36
37
    // The sneak edge check probes down by the step height. EdgeGuard holds
38
    // the probe at the vanilla depth.
39
    @WrapOperation(
40
        method = "maybeBackOffFromEdge(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/MoverType;)Lnet/minecraft/world/phys/Vec3;",
41
        at = @At(value = "INVOKE",
42
            target = "Lnet/minecraft/world/entity/player/Player;maxUpStep()F"))
43
    private float wrapEdgeProbeDepth(Player player, Operation<Float> original) {
44
        float depth = original.call(player);
45
        if (Modules.enabled(EdgeGuard.class)) {
46
            return Math.min(depth, 0.6f);
47
        }
48
        return depth;
49
    }
50
51
    // A landed hit halves the speed and clears the sprint. Sprint can keep both.
52
    @WrapOperation(
53
        method = "causeExtraKnockback(Lnet/minecraft/world/entity/Entity;FLnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/damagesource/DamageSource;FZ)V",
54
        at = @At(value = "INVOKE",
55
            target = "Lnet/minecraft/world/entity/player/Player;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"))
56
    private void wrapHitSlowdown(Player player, Vec3 velocity, Operation<Void> original) {
57
        if (!offlineclient$keepsSprint(player)) {
58
            original.call(player, velocity);
59
        }
60
    }
61
62
    @WrapOperation(
63
        method = "causeExtraKnockback(Lnet/minecraft/world/entity/Entity;FLnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/damagesource/DamageSource;FZ)V",
64
        at = @At(value = "INVOKE",
65
            target = "Lnet/minecraft/world/entity/player/Player;setSprinting(Z)V"))
66
    private void wrapHitSprintStop(Player player, boolean sprinting, Operation<Void> original) {
67
        if (!offlineclient$keepsSprint(player)) {
68
            original.call(player, sprinting);
69
        }
70
    }
71
72
    @Unique
73
    private static boolean offlineclient$keepsSprint(Player player) {
74
        Sprint sprint = Modules.get(Sprint.class);
75
        return player == OfflineClient.MC.player && sprint != null && sprint.keepsSprintOnHit();
76
    }
77
78
    // The physics flag is rebuilt from this every tick. NoClip answers yes.
79
    @WrapOperation(method = "tick()V",
80
        at = @At(value = "INVOKE",
81
            target = "Lnet/minecraft/world/entity/player/Player;isSpectator()Z", ordinal = 0))
82
    private boolean wrapNoPhysics(Player player, Operation<Boolean> original) {
83
        if (original.call(player)) {
84
            return true;
85
        }
86
        NoClip noClip = Modules.get(NoClip.class);
87
        return player == OfflineClient.MC.player && noClip != null && noClip.passesThroughBlocks();
88
    }
89
}
90
PlayerTabOverlayMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PlayerTabOverlayMixin.javaJava · 71 lines · 3.1 KB
@Mixin(PlayerTabOverlay.class)
PlayerTabOverlayMixin.javaJava · 71 lines · 3.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterTab;
4
import com.jellypudding.offlineclient.modules.misc.NameProtect;
5
import com.jellypudding.offlineclient.util.Modules;
6
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
7
import net.minecraft.client.gui.GuiGraphicsExtractor;
8
import net.minecraft.client.gui.components.PlayerTabOverlay;
9
import net.minecraft.client.multiplayer.PlayerInfo;
10
import net.minecraft.network.chat.Component;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
import org.spongepowered.asm.mixin.injection.Constant;
14
import org.spongepowered.asm.mixin.injection.Inject;
15
import org.spongepowered.asm.mixin.injection.ModifyConstant;
16
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17
18
@Mixin(PlayerTabOverlay.class)
19
public class PlayerTabOverlayMixin {
20
21
    @Inject(
22
        method = "extractPingIcon(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIILnet/minecraft/client/multiplayer/PlayerInfo;)V",
23
        at = @At("HEAD"),
24
        cancellable = true)
25
    private void onExtractPingIcon(GuiGraphicsExtractor context, int width, int x, int y,
26
                                   PlayerInfo info, CallbackInfo ci) {
27
        BetterTab tab = BetterTab.get();
28
        if (tab != null && tab.showsPing()) {
29
            tab.drawPing(context, width, x, y, info);
30
            ci.cancel();
31
        }
32
    }
33
34
    @ModifyReturnValue(
35
        method = "getNameForDisplay(Lnet/minecraft/client/multiplayer/PlayerInfo;)Lnet/minecraft/network/chat/Component;",
36
        at = @At("RETURN"))
37
    private Component onGetNameForDisplay(Component original, PlayerInfo info) {
38
        NameProtect nameProtect = Modules.get(NameProtect.class);
39
        if (nameProtect != null) {
40
            original = nameProtect.filter(original);
41
        }
42
        BetterTab tab = BetterTab.get();
43
        return tab == null ? original : tab.decorate(original, info);
44
    }
45
46
    // Vanilla caps the list at eighty sorted players.
47
    @ModifyConstant(method = "getPlayerInfos()Ljava/util/List;", constant = @Constant(longValue = 80L))
48
    private long onPlayerLimit(long original) {
49
        BetterTab tab = BetterTab.get();
50
        return tab == null ? original : tab.playerLimit();
51
    }
52
53
    // The room each row keeps for the ping icon.
54
    @ModifyConstant(
55
        method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V",
56
        constant = @Constant(intValue = 13))
57
    private int onPingRoom(int original) {
58
        BetterTab tab = BetterTab.get();
59
        return tab == null ? original : tab.pingRoom(original);
60
    }
61
62
    // Vanilla wraps to a new column after twenty rows.
63
    @ModifyConstant(
64
        method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;ILnet/minecraft/world/scores/Scoreboard;Lnet/minecraft/world/scores/Objective;)V",
65
        constant = @Constant(intValue = 20))
66
    private int onColumnHeight(int original) {
67
        BetterTab tab = BetterTab.get();
68
        return tab == null ? original : tab.columnHeight();
69
    }
70
}
71
PotentSulfurBlockEntityMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PotentSulfurBlockEntityMixin.javaJava · 30 lines · 1.3 KB
@Mixin(PotentSulfurBlockEntity.class)
PotentSulfurBlockEntityMixin.javaJava · 30 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.AntiPush;
5
import com.jellypudding.offlineclient.util.Modules;
6
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
7
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
8
import net.minecraft.world.entity.Entity;
9
import net.minecraft.world.level.block.entity.PotentSulfurBlockEntity;
10
import net.minecraft.world.phys.Vec3;
11
import org.spongepowered.asm.mixin.Mixin;
12
import org.spongepowered.asm.mixin.injection.At;
13
14
// A geyser launches whatever stands in its column via a block entity
15
// ticker. It is the fifth static lambda and the only push the server never sends.
16
@Mixin(PotentSulfurBlockEntity.class)
17
public abstract class PotentSulfurBlockEntityMixin {
18
19
    @WrapOperation(method = "lambda$static$5",
20
        at = @At(value = "INVOKE",
21
            target = "Lnet/minecraft/world/entity/Entity;addDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"))
22
    private static void wrapGeyserLaunch(Entity entity, Vec3 push, Operation<Void> original) {
23
        AntiPush antiPush = Modules.get(AntiPush.class);
24
        if (entity == OfflineClient.MC.player && antiPush != null && antiPush.blocksGeysers()) {
25
            return;
26
        }
27
        original.call(entity, push);
28
    }
29
}
30
PowderSnowBlockMixinsrc/main/java/com/jellypudding/offlineclient/mixin/PowderSnowBlockMixin.javaJava · 26 lines · 1.1 KB
@Mixin(PowderSnowBlock.class)
PowderSnowBlockMixin.javaJava · 26 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.Jesus;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.world.entity.Entity;
7
import net.minecraft.world.level.block.PowderSnowBlock;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
import org.spongepowered.asm.mixin.injection.Inject;
11
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12
13
@Mixin(PowderSnowBlock.class)
14
public abstract class PowderSnowBlockMixin {
15
16
    // Vanilla asks this for leather boots. A yes gives the snow a solid top.
17
    @Inject(method = "canEntityWalkOnPowderSnow(Lnet/minecraft/world/entity/Entity;)Z",
18
        at = @At("HEAD"), cancellable = true)
19
    private static void onCanWalk(Entity entity, CallbackInfoReturnable<Boolean> cir) {
20
        Jesus jesus = Modules.get(Jesus.class);
21
        if (entity == OfflineClient.MC.player && jesus != null && jesus.walksOnPowderSnow()) {
22
            cir.setReturnValue(true);
23
        }
24
    }
25
}
26
ScreenEffectRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ScreenEffectRendererMixin.javaJava · 77 lines · 3.2 KB
@Mixin(ScreenEffectRenderer.class)
ScreenEffectRendererMixin.javaJava · 77 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ClearView;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.mojang.blaze3d.vertex.PoseStack;
6
import net.minecraft.client.Minecraft;
7
import net.minecraft.client.renderer.ScreenEffectRenderer;
8
import net.minecraft.client.renderer.SubmitNodeCollector;
9
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
10
import org.spongepowered.asm.mixin.Mixin;
11
import org.spongepowered.asm.mixin.Unique;
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
16
@Mixin(ScreenEffectRenderer.class)
17
public class ScreenEffectRendererMixin {
18
19
    // True between the push before the flames and the pop after them.
20
    @Unique
21
    private static boolean offlineclient$loweredFire;
22
23
    @Inject(method = "submitFire", at = @At("HEAD"), cancellable = true)
24
    private static void onSubmitFire(PoseStack poseStack, SubmitNodeCollector collector,
25
                                     TextureAtlasSprite sprite, CallbackInfo ci) {
26
        ClearView clearView = Modules.active(ClearView.class);
27
        if (clearView == null) {
28
            return;
29
        }
30
        if (clearView.blocksFire()) {
31
            ci.cancel();
32
        } else if (clearView.fireOffset() > 0) {
33
            offlineclient$loweredFire = true;
34
            poseStack.pushPose();
35
            poseStack.translate(0, -clearView.fireOffset(), 0);
36
        }
37
    }
38
39
    @Inject(method = "submitFire", at = @At("TAIL"))
40
    private static void afterSubmitFire(PoseStack poseStack, SubmitNodeCollector collector,
41
                                        TextureAtlasSprite sprite, CallbackInfo ci) {
42
        if (offlineclient$loweredFire) {
43
            offlineclient$loweredFire = false;
44
            poseStack.popPose();
45
        }
46
    }
47
48
    @Inject(method = "submitWater", at = @At("HEAD"), cancellable = true)
49
    private static void onSubmitWater(Minecraft minecraft, PoseStack poseStack,
50
                                      SubmitNodeCollector collector, CallbackInfo ci) {
51
        ClearView clearView = Modules.active(ClearView.class);
52
        if (clearView != null && clearView.blocksWater()) {
53
            ci.cancel();
54
        }
55
    }
56
57
    @Inject(method = "submitBlockSprite", at = @At("HEAD"), cancellable = true)
58
    private static void onSubmitBlockSprite(TextureAtlasSprite sprite, PoseStack poseStack,
59
                                            SubmitNodeCollector collector, int light,
60
                                            CallbackInfo ci) {
61
        ClearView clearView = Modules.active(ClearView.class);
62
        if (clearView != null && clearView.blocksBlockInFace()) {
63
            ci.cancel();
64
        }
65
    }
66
67
    // The totem pop and the trial key animation come through here.
68
    @Inject(method = "renderItemActivationAnimation", at = @At("HEAD"), cancellable = true)
69
    private void onItemActivation(PoseStack poseStack, float partialTick,
70
                                  SubmitNodeCollector collector, CallbackInfo ci) {
71
        ClearView clearView = Modules.active(ClearView.class);
72
        if (clearView != null && clearView.blocksTotemPop()) {
73
            ci.cancel();
74
        }
75
    }
76
}
77
ScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ScreenMixin.javaJava · 81 lines · 3.4 KB
@Mixin(Screen.class)
ModifiesScreen
ScreenMixin.javaJava · 81 lines · 3.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.player.GUIMove;
5
import com.jellypudding.offlineclient.modules.player.InvWalk;
6
import com.jellypudding.offlineclient.modules.render.Blur;
7
import com.jellypudding.offlineclient.modules.render.NoBackground;
8
import com.jellypudding.offlineclient.util.Modules;
9
import net.minecraft.client.gui.GuiGraphicsExtractor;
10
import net.minecraft.client.gui.screens.Screen;
11
import net.minecraft.client.input.KeyEvent;
12
import net.minecraft.client.player.LocalPlayer;
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 org.lwjgl.glfw.GLFW;
19
20
@Mixin(Screen.class)
21
public abstract class ScreenMixin {
22
23
    // The dark tint drawn over the world behind an open screen.
24
    @Inject(method = "extractTransparentBackground(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V",
25
        at = @At("HEAD"),
26
        cancellable = true)
27
    private void onExtractTransparentBackground(GuiGraphicsExtractor graphics, CallbackInfo ci) {
28
        NoBackground noBackground = Modules.get(NoBackground.class);
29
        if (noBackground != null && noBackground.clears((Screen) (Object) this)) {
30
            ci.cancel();
31
        }
32
    }
33
34
    // Blur takes over the vanilla menu blur and picks which screens get it.
35
    @Inject(method = "extractBlurredBackground(Lnet/minecraft/client/gui/GuiGraphicsExtractor;)V",
36
        at = @At("HEAD"),
37
        cancellable = true)
38
    private void onExtractBlurredBackground(GuiGraphicsExtractor graphics, CallbackInfo ci) {
39
        Blur blur = Modules.get(Blur.class);
40
        if (blur == null || !blur.isEnabled()) {
41
            return;
42
        }
43
        ci.cancel();
44
        if (blur.wants((Screen) (Object) this)) {
45
            blur.blurHere(graphics);
46
        }
47
    }
48
49
    // Space presses a focused button and the arrows move the focus. Whilst
50
    // InvWalk jumps on space or GUIMove turns on the arrows the screen never sees them.
51
    @Inject(method = "keyPressed(Lnet/minecraft/client/input/KeyEvent;)Z",
52
        at = @At("HEAD"), cancellable = true)
53
    private void onKeyPressed(KeyEvent event, CallbackInfoReturnable<Boolean> cir) {
54
        int key = event.key();
55
        if (key == GLFW.GLFW_KEY_SPACE) {
56
            InvWalk invWalk = Modules.get(InvWalk.class);
57
            if (invWalk != null && invWalk.takesSpace()) {
58
                cir.setReturnValue(true);
59
            }
60
            return;
61
        }
62
        if (key >= GLFW.GLFW_KEY_RIGHT && key <= GLFW.GLFW_KEY_UP) {
63
            GUIMove guiMove = Modules.get(GUIMove.class);
64
            if (guiMove != null && guiMove.takesArrows()) {
65
                cir.setReturnValue(true);
66
            }
67
        }
68
    }
69
70
    // Chat click events that carry a client command run locally instead of going to the server.
71
    @Inject(
72
        method = "clickCommandAction(Lnet/minecraft/client/player/LocalPlayer;Ljava/lang/String;Lnet/minecraft/client/gui/screens/Screen;)V",
73
        at = @At("HEAD"),
74
        cancellable = true)
75
    private static void onClickCommand(LocalPlayer player, String command, Screen screen, CallbackInfo ci) {
76
        if (OfflineClient.INSTANCE.getCommandManager().run(command)) {
77
            ci.cancel();
78
        }
79
    }
80
}
81
SectionCompilerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SectionCompilerMixin.javaJava · 22 lines · 979 B
@Mixin(SectionCompiler.class)
SectionCompilerMixin.javaJava · 22 lines · 979 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.XRay;
4
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
5
import net.minecraft.client.renderer.chunk.SectionCompiler;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.injection.At;
8
import org.spongepowered.asm.mixin.injection.ModifyVariable;
9
10
@Mixin(SectionCompiler.class)
11
public abstract class SectionCompilerMixin {
12
13
    // See through blocks need the translucent layer or their alpha is ignored.
14
    @ModifyVariable(
15
        method = "getOrBeginLayer(Ljava/util/Map;Lnet/minecraft/client/renderer/SectionBufferBuilderPack;Lnet/minecraft/client/renderer/chunk/ChunkSectionLayer;)Lcom/mojang/blaze3d/vertex/BufferBuilder;",
16
        at = @At("HEAD"),
17
        argsOnly = true)
18
    private ChunkSectionLayer onGetOrBeginLayer(ChunkSectionLayer layer) {
19
        return XRay.meshingTranslucent() ? ChunkSectionLayer.TRANSLUCENT : layer;
20
    }
21
}
22
SkyRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SkyRendererMixin.javaJava · 33 lines · 1.2 KB
@Mixin(SkyRenderer.class)
ModifiesSkyRenderer
SkyRendererMixin.javaJava · 33 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Ambience;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.Camera;
6
import net.minecraft.client.multiplayer.ClientLevel;
7
import net.minecraft.client.renderer.SkyRenderer;
8
import net.minecraft.client.renderer.state.level.SkyRenderState;
9
import net.minecraft.world.level.dimension.DimensionType;
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
15
@Mixin(SkyRenderer.class)
16
public abstract class SkyRendererMixin {
17
18
    @Inject(method = "extractRenderState", at = @At("TAIL"))
19
    private void onExtractRenderState(ClientLevel level, float partialTicks, Camera camera,
20
                                      SkyRenderState state, CallbackInfo ci) {
21
        Ambience ambience = Modules.get(Ambience.class);
22
        if (ambience == null) {
23
            return;
24
        }
25
        if (ambience.drawsEndSky()) {
26
            state.skybox = DimensionType.Skybox.END;
27
        }
28
        if (ambience.paintsSky()) {
29
            state.skyColor = ambience.skyColor();
30
        }
31
    }
32
}
33
SlimeBlockMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SlimeBlockMixin.javaJava · 30 lines · 1.3 KB
@Mixin(SlimeBlock.class)
ModifiesSlimeBlock
SlimeBlockMixin.javaJava · 30 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.level.Level;
9
import net.minecraft.world.level.block.SlimeBlock;
10
import net.minecraft.world.level.block.state.BlockState;
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
16
@Mixin(SlimeBlock.class)
17
public abstract class SlimeBlockMixin {
18
19
    // The slime only slows an entity through this call.
20
    @Inject(method = "stepOn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/Entity;)V",
21
        at = @At("HEAD"), cancellable = true)
22
    private void onStepOn(Level level, BlockPos pos, BlockState state, Entity entity,
23
                          CallbackInfo ci) {
24
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
25
        if (entity == OfflineClient.MC.player && noSlowdown != null && noSlowdown.skipsSlime()) {
26
            ci.cancel();
27
        }
28
    }
29
}
30
SoundEngineMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SoundEngineMixin.javaJava · 28 lines · 1.2 KB
@Mixin(SoundEngine.class)
ModifiesSoundEngine
SoundEngineMixin.javaJava · 28 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.SoundBlocker;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.resources.sounds.SoundInstance;
6
import net.minecraft.client.sounds.SoundEngine;
7
import org.spongepowered.asm.mixin.Mixin;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.Inject;
10
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11
12
@Mixin(SoundEngine.class)
13
public abstract class SoundEngineMixin {
14
15
    // Every sound the game plays passes through here whether the server asked for it or not.
16
    @Inject(
17
        method = "play(Lnet/minecraft/client/resources/sounds/SoundInstance;)"
18
            + "Lnet/minecraft/client/sounds/SoundEngine$PlayResult;",
19
        at = @At("HEAD"),
20
        cancellable = true)
21
    private void onPlay(SoundInstance instance, CallbackInfoReturnable<SoundEngine.PlayResult> cir) {
22
        SoundBlocker blocker = Modules.get(SoundBlocker.class);
23
        if (blocker != null && blocker.shouldMute(instance)) {
24
            cir.setReturnValue(SoundEngine.PlayResult.NOT_STARTED);
25
        }
26
    }
27
}
28
SpawnerRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SpawnerRendererMixin.javaJava · 22 lines · 831 B
@Mixin(SpawnerRenderer.class)
SpawnerRendererMixin.javaJava · 22 lines · 831 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.blockentity.SpawnerRenderer;
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.CallbackInfo;
10
11
@Mixin(SpawnerRenderer.class)
12
public abstract class SpawnerRendererMixin {
13
14
    @Inject(method = "submitEntityInSpawner", at = @At("HEAD"), cancellable = true)
15
    private static void onSubmitEntityInSpawner(CallbackInfo ci) {
16
        NoRender noRender = Modules.get(NoRender.class);
17
        if (noRender != null && noRender.hidesSpawnerMobs()) {
18
            ci.cancel();
19
        }
20
    }
21
}
22
SplashManagerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SplashManagerMixin.javaJava · 47 lines · 1.8 KB
@Mixin(SplashManager.class)
SplashManagerMixin.javaJava · 47 lines · 1.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.util.ColorUtil;
4
5
import net.minecraft.client.gui.components.SplashRenderer;
6
import net.minecraft.client.resources.SplashManager;
7
import net.minecraft.network.chat.Component;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.Unique;
10
import org.spongepowered.asm.mixin.injection.At;
11
import org.spongepowered.asm.mixin.injection.Inject;
12
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13
14
import java.util.List;
15
import java.util.concurrent.ThreadLocalRandom;
16
17
// Replaces the vanilla yellow splash with a line in a random vivid colour.
18
@Mixin(SplashManager.class)
19
public class SplashManagerMixin {
20
21
    @Unique
22
    private static final List<String> OFFLINE_SPLASHES = List.of(
23
        "Don't leave me! Don't leave me! I'll die without you!",
24
        "Your mind makes it real!",
25
        "Keep the lights out!",
26
        "How do you know she can't get in here?",
27
        "DON'T you swear at me you little shit!",
28
        "The marquis of snakes!",
29
        "The rest is confetti.",
30
        "It's you. It's me. It's us.",
31
        "It could be a stranger in a crowd.",
32
        "What is the opposite of a miracle?"
33
    );
34
35
    @Inject(
36
        method = "getSplash()Lnet/minecraft/client/gui/components/SplashRenderer;",
37
        at = @At("HEAD"),
38
        cancellable = true)
39
    private void onGetSplash(CallbackInfoReturnable<SplashRenderer> cir) {
40
        ThreadLocalRandom random = ThreadLocalRandom.current();
41
        String line = OFFLINE_SPLASHES.get(random.nextInt(OFFLINE_SPLASHES.size()));
42
        int color = ColorUtil.hsv(
43
            random.nextFloat(360f), 0.85f, 1f) & 0xFFFFFF;
44
        cir.setReturnValue(new SplashRenderer(Component.literal(line).withColor(color)));
45
    }
46
}
47
StringUtilMixinsrc/main/java/com/jellypudding/offlineclient/mixin/StringUtilMixin.javaJava · 23 lines · 920 B
@Mixin(StringUtil.class)
ModifiesStringUtil
StringUtilMixin.javaJava · 23 lines · 920 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.misc.BetterChat;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.util.StringUtil;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.injection.At;
8
import org.spongepowered.asm.mixin.injection.ModifyArg;
9
10
@Mixin(StringUtil.class)
11
public abstract class StringUtilMixin {
12
13
    // The only caller is the chat cut off. Raising it here raises nothing else.
14
    @ModifyArg(method = "trimChatMessage",
15
        at = @At(value = "INVOKE",
16
            target = "Lnet/minecraft/util/StringUtil;truncateStringIfNecessary(Ljava/lang/String;IZ)Ljava/lang/String;"),
17
        index = 1)
18
    private static int chatLimit(int max) {
19
        BetterChat betterChat = Modules.get(BetterChat.class);
20
        return betterChat != null && betterChat.liftsBoxLimit() ? Integer.MAX_VALUE : max;
21
    }
22
}
23
SubmitNodeCollectionMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SubmitNodeCollectionMixin.javaJava · 24 lines · 1.1 KB
@Mixin(SubmitNodeCollection.class)
SubmitNodeCollectionMixin.javaJava · 24 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ChestEsp;
4
import net.minecraft.client.renderer.SubmitNodeCollection;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.injection.At;
7
import org.spongepowered.asm.mixin.injection.ModifyVariable;
8
9
// A model submitted with an outline colour is drawn into the glow buffer as well.
10
@Mixin(SubmitNodeCollection.class)
11
public abstract class SubmitNodeCollectionMixin {
12
13
    // The outline colour is the fourth int argument after light and overlay and tint.
14
    @ModifyVariable(method = "submitModel(Lnet/minecraft/client/model/Model;Ljava/lang/Object;"
15
        + "Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/rendertype/RenderType;III"
16
        + "Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;I"
17
        + "Lnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V",
18
        at = @At("HEAD"), argsOnly = true, ordinal = 3)
19
    private int onOutlineColor(int outline) {
20
        int glow = ChestEsp.currentGlow();
21
        return glow != 0 ? glow : outline;
22
    }
23
}
24
SweetBerryBushBlockMixinsrc/main/java/com/jellypudding/offlineclient/mixin/SweetBerryBushBlockMixin.javaJava · 32 lines · 1.5 KB
@Mixin(SweetBerryBushBlock.class)
SweetBerryBushBlockMixin.javaJava · 32 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.entity.InsideBlockEffectApplier;
9
import net.minecraft.world.level.Level;
10
import net.minecraft.world.level.block.SweetBerryBushBlock;
11
import net.minecraft.world.level.block.state.BlockState;
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
17
@Mixin(SweetBerryBushBlock.class)
18
public abstract class SweetBerryBushBlockMixin {
19
20
    // The bush slows and pricks an entity through this call.
21
    @Inject(method = "entityInside(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/InsideBlockEffectApplier;Z)V",
22
        at = @At("HEAD"), cancellable = true)
23
    private void onEntityInside(BlockState state, Level level, BlockPos pos, Entity entity,
24
                                InsideBlockEffectApplier applier, boolean precise, CallbackInfo ci) {
25
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
26
        if (entity == OfflineClient.MC.player && noSlowdown != null
27
            && noSlowdown.skipsBerryBushes()) {
28
            ci.cancel();
29
        }
30
    }
31
}
32
TitleScreenMixinsrc/main/java/com/jellypudding/offlineclient/mixin/TitleScreenMixin.javaJava · 129 lines · 4.8 KB
@Mixin(TitleScreen.class)
ModifiesTitleScreen
TitleScreenMixin.javaJava · 129 lines · 4.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.gui.RecoveryScreen;
5
import com.jellypudding.offlineclient.util.ColorUtil;
6
import com.jellypudding.offlineclient.util.RenderUtil;
7
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
8
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
9
import net.minecraft.client.gui.Font;
10
import net.minecraft.client.gui.GuiGraphicsExtractor;
11
import net.minecraft.client.gui.components.AbstractWidget;
12
import net.minecraft.client.gui.components.Button;
13
import net.minecraft.client.gui.components.events.GuiEventListener;
14
import net.minecraft.client.gui.screens.Screen;
15
import net.minecraft.client.gui.screens.TitleScreen;
16
import net.minecraft.network.chat.Component;
17
import net.minecraft.util.Mth;
18
import net.minecraft.util.Util;
19
import org.spongepowered.asm.mixin.Final;
20
import org.spongepowered.asm.mixin.Mixin;
21
import org.spongepowered.asm.mixin.Shadow;
22
import org.spongepowered.asm.mixin.Unique;
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
27
import java.util.concurrent.ThreadLocalRandom;
28
29
@Mixin(TitleScreen.class)
30
public abstract class TitleScreenMixin extends Screen {
31
32
    @Shadow
33
    @Final
34
    private static Component COPYRIGHT_TEXT;
35
36
    @Shadow
37
    private boolean fading;
38
39
    @Shadow
40
    private long fadeInStart;
41
42
    @Unique
43
    private int offlineclient$creditColorFrom;
44
45
    @Unique
46
    private int offlineclient$creditColorTo;
47
48
    @Unique
49
    private int offlineclient$versionColor;
50
51
    @Unique
52
    private int offlineclient$creditY = -1;
53
54
    private TitleScreenMixin(OfflineClient client, Component title) {
55
        super(title);
56
    }
57
58
    // Swaps the vanilla copyright line in the bottom right for the developer credit.
59
    @Inject(method = "init()V", at = @At("TAIL"))
60
    private void onInit(CallbackInfo ci) {
61
        float hue = ThreadLocalRandom.current().nextFloat(360f);
62
        offlineclient$creditColorFrom = ColorUtil.hsv(hue, 0.8f, 1f);
63
        offlineclient$creditColorTo = ColorUtil.hsv(hue + 80f, 0.8f, 1f);
64
        offlineclient$versionColor =
65
            ColorUtil.hsv(ThreadLocalRandom.current().nextFloat(360f), 0.8f, 1f);
66
67
        AbstractWidget copyright = null;
68
        for (GuiEventListener child : children()) {
69
            if (child instanceof AbstractWidget widget
70
                && COPYRIGHT_TEXT.equals(widget.getMessage())) {
71
                copyright = widget;
72
                break;
73
            }
74
        }
75
        if (copyright != null) {
76
            offlineclient$creditY = copyright.getY();
77
            removeWidget(copyright);
78
        }
79
80
        // A way back to defaults when a saved setting breaks the game.
81
        addRenderableWidget(Button.builder(
82
                Component.literal("Recovery"),
83
                button -> minecraft.gui.setScreen(
84
                    new RecoveryScreen(this)))
85
            .bounds(width - 62, 4, 58, 16)
86
            .build());
87
    }
88
89
    @Inject(
90
        method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
91
        at = @At("TAIL"))
92
    private void onRender(GuiGraphicsExtractor context, int mouseX, int mouseY,
93
                          float partialTicks, CallbackInfo ci) {
94
        Font font = minecraft.font;
95
        float alpha = offlineclient$fadeAlpha();
96
97
        String name = OfflineClient.NAME + " v" + OfflineClient.VERSION;
98
        RenderUtil.rainbowText(context, font, name, 4, 4, 1f, alpha);
99
100
        String credit = "Developed by AlphaAlex115";
101
        int y = offlineclient$creditY != -1 ? offlineclient$creditY : height - 10;
102
        RenderUtil.gradientText(context, font, credit, width - font.width(credit) - 2, y,
103
            offlineclient$creditColorFrom, offlineclient$creditColorTo, alpha);
104
    }
105
106
    @Unique
107
    private float offlineclient$fadeAlpha() {
108
        if (!fading) {
109
            return 1f;
110
        }
111
        if (fadeInStart == 0L) {
112
            return 0f;
113
        }
114
        float t = (Util.getMillis() - fadeInStart) / 2000f;
115
        return Mth.clampedMap(Mth.clamp(t, 0f, 1f), 0.5f, 1f, 0f, 1f);
116
    }
117
118
    // The top byte carries the fade alpha.
119
    @WrapOperation(
120
        method = "extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
121
        at = @At(value = "INVOKE",
122
            target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;text(Lnet/minecraft/client/gui/Font;Ljava/lang/String;III)V"))
123
    private void wrapVersionText(GuiGraphicsExtractor context, Font font, String text,
124
                                 int x, int y, int color, Operation<Void> original) {
125
        int recolored = (color & 0xFF000000) | (offlineclient$versionColor & 0xFFFFFF);
126
        original.call(context, font, text, x, y, recolored);
127
    }
128
}
129
ToastManagerMixinsrc/main/java/com/jellypudding/offlineclient/mixin/ToastManagerMixin.javaJava · 24 lines · 929 B
@Mixin(ToastManager.class)
ModifiesToastManager
ToastManagerMixin.javaJava · 24 lines · 929 B · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.ClearView;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.gui.components.toasts.Toast;
6
import net.minecraft.client.gui.components.toasts.ToastManager;
7
import org.spongepowered.asm.mixin.Mixin;
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
12
// Every pop up in the top right corner comes through here.
13
@Mixin(ToastManager.class)
14
public abstract class ToastManagerMixin {
15
16
    @Inject(method = "addToast", at = @At("HEAD"), cancellable = true)
17
    private void onAddToast(Toast toast, CallbackInfo ci) {
18
        ClearView clearView = Modules.active(ClearView.class);
19
        if (clearView != null && clearView.blocksToast(toast)) {
20
            ci.cancel();
21
        }
22
    }
23
}
24
TooltipDisplayMixinsrc/main/java/com/jellypudding/offlineclient/mixin/TooltipDisplayMixin.javaJava · 28 lines · 1.2 KB
@Mixin(TooltipDisplay.class)
TooltipDisplayMixin.javaJava · 28 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.BetterTooltips;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
6
import net.minecraft.world.item.component.TooltipDisplay;
7
import org.objectweb.asm.Opcodes;
8
import org.spongepowered.asm.mixin.Mixin;
9
import org.spongepowered.asm.mixin.injection.At;
10
11
@Mixin(TooltipDisplay.class)
12
public abstract class TooltipDisplayMixin {
13
14
    @ModifyExpressionValue(method = "shows", at = @At(value = "FIELD",
15
        target = "Lnet/minecraft/world/item/component/TooltipDisplay;hideTooltip:Z", opcode = Opcodes.GETFIELD))
16
    private boolean onHideTooltip(boolean hidden) {
17
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
18
        return hidden && (tooltips == null || !tooltips.showsHiddenTooltips());
19
    }
20
21
    @ModifyExpressionValue(method = "shows", at = @At(value = "INVOKE",
22
        target = "Ljava/util/SequencedSet;contains(Ljava/lang/Object;)Z"))
23
    private boolean onHiddenLine(boolean hidden) {
24
        BetterTooltips tooltips = Modules.get(BetterTooltips.class);
25
        return hidden && (tooltips == null || !tooltips.showsHiddenLines());
26
    }
27
}
28
TridentItemMixinsrc/main/java/com/jellypudding/offlineclient/mixin/TridentItemMixin.javaJava · 35 lines · 1.5 KB
@Mixin(TridentItem.class)
ModifiesTridentItem
TridentItemMixin.javaJava · 35 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.movement.TridentBoost;
4
import com.jellypudding.offlineclient.util.Modules;
5
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
6
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
7
import net.minecraft.world.entity.player.Player;
8
import net.minecraft.world.item.TridentItem;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
12
@Mixin(TridentItem.class)
13
public abstract class TridentItemMixin {
14
15
    // The riptide launch is one push on the player.
16
    @WrapOperation(method = "releaseUsing",
17
        at = @At(value = "INVOKE",
18
            target = "Lnet/minecraft/world/entity/player/Player;push(DDD)V"))
19
    private void wrapRiptidePush(Player player, double x, double y, double z,
20
                                 Operation<Void> original) {
21
        TridentBoost boost = Modules.get(TridentBoost.class);
22
        double scale = boost == null ? 1 : boost.multiplier();
23
        original.call(player, x * scale, y * scale, z * scale);
24
    }
25
26
    // Both the draw and the release refuse a riptide on dry land.
27
    @WrapOperation(method = {"use", "releaseUsing"},
28
        at = @At(value = "INVOKE",
29
            target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z"))
30
    private boolean wrapWetCheck(Player player, Operation<Boolean> original) {
31
        TridentBoost boost = Modules.get(TridentBoost.class);
32
        return (boost != null && boost.allowsDryLand()) || original.call(player);
33
    }
34
}
35
VisGraphMixinsrc/main/java/com/jellypudding/offlineclient/mixin/VisGraphMixin.javaJava · 27 lines · 1.1 KB
@Mixin(VisGraph.class)
ModifiesVisGraph
VisGraphMixin.javaJava · 27 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.Freecam;
4
import com.jellypudding.offlineclient.modules.render.NoRender;
5
import com.jellypudding.offlineclient.util.Modules;
6
import net.minecraft.client.renderer.chunk.VisGraph;
7
import net.minecraft.core.BlockPos;
8
import org.spongepowered.asm.mixin.Mixin;
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
13
// A chunk meshed whilst Freecam is on treats every block as see through. The
14
// camera can then look into rooms the player's side would have culled.
15
// NoRender asks for the same when nothing behind a wall may be skipped.
16
@Mixin(VisGraph.class)
17
public abstract class VisGraphMixin {
18
19
    @Inject(method = "setOpaque(Lnet/minecraft/core/BlockPos;)V", at = @At("HEAD"), cancellable = true)
20
    private void onSetOpaque(BlockPos pos, CallbackInfo ci) {
21
        NoRender noRender = Modules.get(NoRender.class);
22
        if (Modules.enabled(Freecam.class) || (noRender != null && noRender.skipsCaveCulling())) {
23
            ci.cancel();
24
        }
25
    }
26
}
27
WebBlockMixinsrc/main/java/com/jellypudding/offlineclient/mixin/WebBlockMixin.javaJava · 36 lines · 1.7 KB
@Mixin(WebBlock.class)
ModifiesWebBlock
WebBlockMixin.javaJava · 36 lines · 1.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.modules.movement.NoSlowdown;
5
import com.jellypudding.offlineclient.modules.movement.NoWeb;
6
import com.jellypudding.offlineclient.util.Modules;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.world.entity.Entity;
9
import net.minecraft.world.entity.InsideBlockEffectApplier;
10
import net.minecraft.world.level.Level;
11
import net.minecraft.world.level.block.WebBlock;
12
import net.minecraft.world.level.block.state.BlockState;
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
18
@Mixin(WebBlock.class)
19
public abstract class WebBlockMixin {
20
21
    // The web only slows an entity through this call.
22
    @Inject(method = "entityInside(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/InsideBlockEffectApplier;Z)V",
23
        at = @At("HEAD"), cancellable = true)
24
    private void onEntityInside(BlockState state, Level level, BlockPos pos, Entity entity,
25
                                InsideBlockEffectApplier applier, boolean precise, CallbackInfo ci) {
26
        if (entity != OfflineClient.MC.player) {
27
            return;
28
        }
29
        NoWeb noWeb = Modules.get(NoWeb.class);
30
        NoSlowdown noSlowdown = Modules.get(NoSlowdown.class);
31
        if ((noWeb != null && noWeb.skipsWebs()) || (noSlowdown != null && noSlowdown.skipsWebs())) {
32
            ci.cancel();
33
        }
34
    }
35
}
36
WorldBorderMixinsrc/main/java/com/jellypudding/offlineclient/mixin/WorldBorderMixin.javaJava · 39 lines · 1.5 KB
@Mixin(WorldBorder.class)
ModifiesWorldBorder
WorldBorderMixin.javaJava · 39 lines · 1.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.world.Collisions;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.world.entity.Entity;
7
import net.minecraft.world.level.border.WorldBorder;
8
import net.minecraft.world.phys.AABB;
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.CallbackInfoReturnable;
13
14
// The two calls that decide whether the border stops you.
15
@Mixin(WorldBorder.class)
16
public abstract class WorldBorderMixin {
17
18
    @Inject(method = "isInsideCloseToBorder(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z",
19
        at = @At("HEAD"), cancellable = true)
20
    private void onIsInsideCloseToBorder(Entity entity, AABB box, CallbackInfoReturnable<Boolean> cir) {
21
        if (ignored()) {
22
            cir.setReturnValue(false);
23
        }
24
    }
25
26
    @Inject(method = "isWithinBounds(Lnet/minecraft/core/BlockPos;)Z",
27
        at = @At("HEAD"), cancellable = true)
28
    private void onIsWithinBounds(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
29
        if (ignored()) {
30
            cir.setReturnValue(true);
31
        }
32
    }
33
34
    private static boolean ignored() {
35
        Collisions collisions = Modules.active(Collisions.class);
36
        return collisions != null && collisions.ignoresBorder();
37
    }
38
}
39
WorldBorderRendererMixinsrc/main/java/com/jellypudding/offlineclient/mixin/WorldBorderRendererMixin.javaJava · 26 lines · 1.1 KB
@Mixin(WorldBorderRenderer.class)
WorldBorderRendererMixin.javaJava · 26 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.mixin;
2
3
import com.jellypudding.offlineclient.modules.render.NoRender;
4
import com.jellypudding.offlineclient.util.Modules;
5
import net.minecraft.client.renderer.WorldBorderRenderer;
6
import net.minecraft.client.renderer.state.level.WorldBorderRenderState;
7
import net.minecraft.world.phys.Vec3;
8
import org.spongepowered.asm.mixin.Mixin;
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
13
@Mixin(WorldBorderRenderer.class)
14
public abstract class WorldBorderRendererMixin {
15
16
    @Inject(method = "render(Lnet/minecraft/client/renderer/state/level/WorldBorderRenderState;Lnet/minecraft/world/phys/Vec3;DD)V",
17
        at = @At("HEAD"), cancellable = true)
18
    private void onRender(WorldBorderRenderState state, Vec3 camera, double width, double height,
19
                          CallbackInfo ci) {
20
        NoRender noRender = Modules.get(NoRender.class);
21
        if (noRender != null && noRender.hidesWorldBorder()) {
22
            ci.cancel();
23
        }
24
    }
25
}
26