aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/dwarven/Puzzler.java
blob: 400f40ff1c3197301a6113d6b25b47aa5a918502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package de.hysky.skyblocker.skyblock.dwarven;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.chat.ChatFilterResult;
import de.hysky.skyblocker.utils.chat.ChatPatternListener;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;

import java.util.regex.Matcher;

public class Puzzler extends ChatPatternListener {
    public Puzzler() {
        super("^\\[NPC] Puzzler: ((?:▲|▶|◀|▼){10})$");
    }

    @Override
    public ChatFilterResult state() {
        return SkyblockerConfigManager.get().mining.dwarvenMines.solvePuzzler ? null : ChatFilterResult.PASS;
    }

    @Override
    public boolean onMatch(Text message, Matcher matcher) {
        int x = 181;
        int z = 135;
        for (char c : matcher.group(1).toCharArray()) {
            if (c == '▲') z++;
            else if (c == '▼') z--;
            else if (c == '◀') x++;
            else if (c == '▶') x--;
        }
        ClientWorld world = MinecraftClient.getInstance().world;
        if (world != null)
            world.setBlockState(new BlockPos(x, 195, z), Blocks.CRIMSON_PLANKS.getDefaultState());
        return false;
    }
}