AutoSign module

AutoSign: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), OfflineClient).

2 implementationsMISCWORLD

Full module source: 2 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)MISCsrc/main/java/thunder/hack/features/modules/misc/AutoSign.javaJava · 70 lines · 3.4 KB

Automatically places text onto signs.

SettingsLine1Line2Line3Line4DateFormatGlowing
AutoSign.javaJava · Minecraft 26.2 · 70 lines · 3.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.misc;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.ChatFormatting;
5
import net.minecraft.client.gui.screens.inventory.SignEditScreen;
6
import net.minecraft.core.Direction;
7
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
8
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
9
import net.minecraft.world.InteractionHand;
10
import net.minecraft.world.item.Items;
11
import net.minecraft.world.phys.BlockHitResult;
12
import thunder.hack.events.impl.EventScreen;
13
import thunder.hack.injection.accesors.ISignEditScreen;
14
import thunder.hack.features.modules.Module;
15
import thunder.hack.setting.Setting;
16
import thunder.hack.utility.player.InventoryUtility;
17
import thunder.hack.utility.player.SearchInvResult;
18
19
import java.text.SimpleDateFormat;
20
import java.util.Date;
21
22
import static thunder.hack.features.modules.client.ClientSettings.isRu;
23
24
public class AutoSign extends Module {
25
    public AutoSign() {
26
        super("AutoSign", Category.MISC);
27
    }
28
29
    private final Setting<String> line1 = new Setting<>("Line1", "<player>");
30
    private final Setting<String> line2 = new Setting<>("Line2", "was here");
31
    private final Setting<String> line3 = new Setting<>("Line3", "<------------->");
32
    private final Setting<String> line4 = new Setting<>("Line4", "<date>");
33
    private final Setting<String> dateFormat = new Setting<>("DateFormat", "dd/MM/yyyy",
34
            v -> line1.getValue().contains("<date>") || line2.getValue().contains("<date>") || line3.getValue().contains("<date>") || line4.getValue().contains("<date>"));
35
    private final Setting<Boolean> glow = new Setting<>("Glowing", false);
36
37
    @EventHandler
38
    public void onScreen(EventScreen e) {
39
        if (e.getScreen() instanceof SignEditScreen ses) {
40
            e.cancel();
41
            sendPacketSilent(new ServerboundSignUpdatePacket(((ISignEditScreen) ses).getBlockEntity().getBlockPos(), ((ISignEditScreen) ses).isFront(), format(line1.getValue()), format(line2.getValue()), format(line3.getValue()), format(line4.getValue())));
42
43
            if (glow.getValue()) {
44
                SearchInvResult result = InventoryUtility.findItemInHotBar(Items.GLOW_INK_SAC);
45
                boolean offhand = mc.player.getOffhandItem().getItem() == Items.GLOW_INK_SAC;
46
                if (result.found() || offhand) {
47
                    InventoryUtility.saveSlot();
48
                    result.switchTo();
49
                    mc.gameMode.useItemOn(mc.player, offhand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND,
50
                            new BlockHitResult(net.minecraft.world.phys.Vec3.atBottomCenterOf(((ISignEditScreen) ses).getBlockEntity().getBlockPos()).add(0, 0.5, 0), Direction.UP, ((ISignEditScreen) ses).getBlockEntity().getBlockPos(), false));
51
                    sendPacket(new ServerboundSwingPacket(offhand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND));
52
                    InventoryUtility.returnSlot();
53
                }
54
            }
55
        }
56
    }
57
58
    public String format(String s) {
59
        String format = "dd/MM/yyyy";
60
61
        try {
62
            format = new SimpleDateFormat(dateFormat.getValue()).format(new Date());
63
        } catch (Exception e) {
64
            sendMessage(ChatFormatting.RED + (isRu() ? "У тебя не правильный формат даты!" : "Your date format is wrong!"));
65
        }
66
67
        return s.replace("<player>", mc.getUser().getName()).replace("<date>", format);
68
    }
69
}
70
OfflineClientWORLDsrc/main/java/com/jellypudding/offlineclient/modules/world/AutoSign.javaJava · 112 lines · 4.1 KB

Writes your set text onto every sign you place.

SettingsSourceLine 1Line 2Line 3Line 4Delay
AutoSign.javaJava · Minecraft 26.2 · 112 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.world;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.ClientTickEvent;
5
import com.jellypudding.offlineclient.event.events.PacketSendEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.setting.EnumSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.setting.TextSetting;
11
import com.jellypudding.offlineclient.util.ChatUtil;
12
import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen;
13
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
14
15
// Fills every placed sign with the same four lines and closes the screen.
16
public final class AutoSign extends Module {
17
18
    private static final int LINES = 4;
19
20
    public enum Source { TYPED, FIRST_SIGN }
21
22
    private final EnumSetting<Source> source = new EnumSetting<>("Source",
23
        "Where the text comes from.", Source.TYPED)
24
        .describe(Source.TYPED, "The four lines set below.")
25
        .describe(Source.FIRST_SIGN, "Copies whatever you write on the next sign by hand.");
26
    private final TextSetting line1 = new TextSetting("Line 1", "Top line of the sign.", "")
27
        .under(source, Source.TYPED);
28
    private final TextSetting line2 = new TextSetting("Line 2", "Second line of the sign.", "")
29
        .under(source, Source.TYPED);
30
    private final TextSetting line3 = new TextSetting("Line 3", "Third line of the sign.", "")
31
        .under(source, Source.TYPED);
32
    private final TextSetting line4 = new TextSetting("Line 4", "Bottom line of the sign.", "")
33
        .under(source, Source.TYPED);
34
    private final NumberSetting delay = new NumberSetting("Delay",
35
        "Ticks to wait before the sign is sent. Servers dislike an instant reply.",
36
        10, 0, 60, 1, " ticks").min(0);
37
38
    private AbstractSignEditScreen filled;
39
    private String[] learned;
40
    private int timer;
41
    private int written;
42
43
    public AutoSign() {
44
        super("AutoSign", "Writes your set text onto every sign you place.", Category.WORLD);
45
        addSettings(source, line1, line2, line3, line4, delay);
46
        searchTags("sign", "text");
47
    }
48
49
    @Override
50
    public String getSuffix() {
51
        if (source.is(Source.FIRST_SIGN) && learned == null) {
52
            return "waiting for a sign";
53
        }
54
        return written == 0 ? null : written + " signed";
55
    }
56
57
    @Override
58
    protected void onEnable() {
59
        filled = null;
60
        learned = null;
61
        timer = 0;
62
        written = 0;
63
    }
64
65
    // The lines you send by hand become the template for every sign after it.
66
    @Subscribe
67
    private void onPacketSend(PacketSendEvent event) {
68
        if (!(event.getPacket() instanceof ServerboundSignUpdatePacket packet)) {
69
            return;
70
        }
71
        boolean first = learned == null;
72
        learned = packet.getLines().clone();
73
        if (first && source.is(Source.FIRST_SIGN)) {
74
            ChatUtil.message("§bAutoSign §7copied that sign.");
75
        }
76
    }
77
78
    @Subscribe
79
    private void onClientTick(ClientTickEvent event) {
80
        if (!(mc.gui.screen() instanceof AbstractSignEditScreen screen)) {
81
            filled = null;
82
            return;
83
        }
84
        String[] lines = lines();
85
        // Nothing learned yet. The screen is left for you to type into.
86
        if (lines == null) {
87
            return;
88
        }
89
        if (screen != filled) {
90
            filled = screen;
91
            timer = delay.getInt();
92
            System.arraycopy(lines, 0, screen.messages, 0,
93
                Math.min(LINES, screen.messages.length));
94
        }
95
        if (timer > 0) {
96
            timer--;
97
            return;
98
        }
99
        // Closing the screen is what sends the finished sign.
100
        mc.gui.setScreen(null);
101
        filled = null;
102
        written++;
103
    }
104
105
    private String[] lines() {
106
        if (source.is(Source.FIRST_SIGN)) {
107
            return learned;
108
        }
109
        return new String[]{line1.getValue(), line2.getValue(), line3.getValue(), line4.getValue()};
110
    }
111
}
112