aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CommissionLabels.java
blob: f3e8e935cc2758e216035015bdd9203f6136577c (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package de.hysky.skyblocker.skyblock.dwarven;

import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class CommissionLabels {

    private static final Map<String, MiningLocationLabels.dwarvenCategory> DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabels.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabels.dwarvenCategory::toString, Function.identity()));
    private static final Map<String, MiningLocationLabels.glaciteCategory> GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabels.glaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabels.glaciteCategory::toString, Function.identity()));


    protected static List<MiningLocationLabels> activeWaypoints = new ArrayList<>();

    public static void init() {
        WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render);
        ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset());
    }

    protected static void update(List<String> newCommissions) {
        System.out.println(newCommissions);
        activeWaypoints.clear();
        String location = Utils.getIslandArea().substring(2);
        //find commission locations in glacite
        if (location.equals("Dwarven Base Camp") || location.equals("Glacite Tunnels")) {
            for (String commission : newCommissions) {
                for (Map.Entry<String, MiningLocationLabels.glaciteCategory> glaciteLocation : GLACITE_LOCATIONS.entrySet()) {
                    if (commission.contains(glaciteLocation.getKey())) {
                        MiningLocationLabels.glaciteCategory category = glaciteLocation.getValue();
                        for (BlockPos gemstoneLocation : category.getLocations()) {
                            activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), gemstoneLocation));
                        }
                    }
                }
            }
            return;
        }
        //find commission locations in dwarven mines
        for (String commission : newCommissions) {
            for (Map.Entry<String, MiningLocationLabels.dwarvenCategory> dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) {
                if (commission.contains(dwarvenLocation.getKey())) {
                    MiningLocationLabels.dwarvenCategory category = dwarvenLocation.getValue();
                    activeWaypoints.add(new MiningLocationLabels(category, Text.of(category.getName()), category.getLocation()));
                }
            }
        }
    }

    private static void render(WorldRenderContext context) {
        if (!Utils.isInDwarvenMines()) {
            return;
        }
        for (MiningLocationLabels MiningLocationLabels : activeWaypoints) {
            MiningLocationLabels.render(context);
        }
        
    }

    private static void reset() {

    }
}