package de.hysky.skyblocker.skyblock.dwarven; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; 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 DWARVEN_LOCATIONS = Arrays.stream(MiningLocationLabel.dwarvenCategory.values()).collect(Collectors.toMap(MiningLocationLabel.dwarvenCategory::toString, Function.identity())); private static final Map GLACITE_LOCATIONS = Arrays.stream(MiningLocationLabel.glaciteCategory.values()).collect(Collectors.toMap(MiningLocationLabel.glaciteCategory::toString, Function.identity())); protected static List activeWaypoints = new ArrayList<>(); public static void init() { WorldRenderEvents.AFTER_TRANSLUCENT.register(CommissionLabels::render); } protected static void update(List newCommissions) { if (!SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; } 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 glaciteLocation : GLACITE_LOCATIONS.entrySet()) { if (commission.contains(glaciteLocation.getKey())) { MiningLocationLabel.glaciteCategory category = glaciteLocation.getValue(); for (BlockPos gemstoneLocation : category.getLocations()) { activeWaypoints.add(new MiningLocationLabel(category, gemstoneLocation)); } } } } //add base waypoint if enabled if (SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.showBaseCamp) { activeWaypoints.add(new MiningLocationLabel(MiningLocationLabel.glaciteCategory.CAMPFIRE, MiningLocationLabel.glaciteCategory.CAMPFIRE.getLocations()[0])); } return; } //find commission locations in dwarven mines for (String commission : newCommissions) { for (Map.Entry dwarvenLocation : DWARVEN_LOCATIONS.entrySet()) { if (commission.contains(dwarvenLocation.getKey())) { MiningLocationLabel.dwarvenCategory category = dwarvenLocation.getValue(); category.isTitanium = commission.contains("Titanium"); activeWaypoints.add(new MiningLocationLabel(category, category.getLocation())); } } } } private static void render(WorldRenderContext context) { if (!Utils.isInDwarvenMines() || !SkyblockerConfigManager.get().locations.dwarvenMines.commissionWaypoints.enabled) { return; } for (MiningLocationLabel MiningLocationLabel : activeWaypoints) { MiningLocationLabel.render(context); } } }