aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/EffigyWaypoints.java
blob: 7376c896752cb321f59b1d68f3f78b0d4be439a2 (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
70
71
72
73
74
75
76
77
78
79
package me.xmrvizzy.skyblocker.skyblock.rift;

import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.utils.RenderHelper;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreboardObjective;
import net.minecraft.scoreboard.ScoreboardPlayerScore;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class EffigyWaypoints {
    private static final Logger LOGGER = LoggerFactory.getLogger(EffigyWaypoints.class);
    private static final List<BlockPos> effigies = List.of(
            new BlockPos(150, 79, 95), //Effigy 1
            new BlockPos(193, 93, 119), //Effigy 2
            new BlockPos(235, 110, 147), //Effigy 3
            new BlockPos(293, 96, 134), //Effigy 4
            new BlockPos(262, 99, 94), //Effigy 5
            new BlockPos(240, 129, 118) //Effigy 6
    );
    private static final List<BlockPos> unBrokenEffigies = new ArrayList<>();

    protected static void updateEffigies() {
        if (!SkyblockerConfig.get().slayer.vampireSlayer.enableEffigyWaypoints || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) return;

        unBrokenEffigies.clear();
        try {
            ClientPlayerEntity player = MinecraftClient.getInstance().player;
            if (player == null) return;
            Scoreboard scoreboard = player.getScoreboard();
            ScoreboardObjective objective = scoreboard.getObjectiveForSlot(1);
            for (ScoreboardPlayerScore score : scoreboard.getAllPlayerScores(objective)) {
                Team team = scoreboard.getPlayerTeam(score.getPlayerName());
                if (team != null) {
                    String line = team.getPrefix().getString() + team.getSuffix().getString();
                    if (line.contains("Effigies")) {
                        List<Text> newList = new ArrayList<>(team.getPrefix().getSiblings());
                        newList.addAll(team.getSuffix().getSiblings());
                        for (int i = 1; i < newList.size(); i++) {
                            if (newList.get(i).getStyle().getColor() == TextColor.parse("gray")) {
                                unBrokenEffigies.add(effigies.get(i - 1));
                            }
                        }
                    }
                }
            }
        } catch (NullPointerException e) {
            LOGGER.error("[Skyblocker] Error while updating effigies.", e);
        }
    }

    protected static void render(WorldRenderContext context) {
        if (SkyblockerConfig.get().slayer.vampireSlayer.enableEffigyWaypoints && Utils.getLocation().contains("Stillgore Château")) {
            for (BlockPos effigy : unBrokenEffigies) {
                float[] colorComponents = DyeColor.RED.getColorComponents();
                if (SkyblockerConfig.get().slayer.vampireSlayer.compactEffigyWaypoints) {
                    RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, effigy.down(6), colorComponents, 0.5F);
                } else {
                    RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, effigy, colorComponents, 0.5F);
                    for (int i = 1; i < 6; i++) {
                        RenderHelper.renderFilledThroughWalls(context, effigy.down(i), colorComponents, 0.5F - (0.075F * i));
                    }
                }
            }
        }
    }
}