Search in sources :

Example 1 with Location

use of com.wynntils.core.utils.objects.Location in project Wynntils by Wynntils.

the class LootRunPath method generatePoints.

private Pair<List<LootRunPath.LootRunPathLocation>, List<Vector3d>> generatePoints(int sampleRate) {
    Pair<List<Location>, List<Vector3d>> sample = spline.sample(sampleRate);
    List<Location> rawLocations = sample.a;
    List<LootRunPath.LootRunPathLocation> locations = new ArrayList<>();
    Iterator<CustomColor> colorIterator = COLORS.iterator();
    CustomColor currentColor = null;
    CustomColor nextColor = colorIterator.next();
    float changeRed = 0;
    float changeGreen = 0;
    float changeBlue = 0;
    for (int i = 0; i < rawLocations.size(); i++) {
        if (i % (sampleRate * MapConfig.LootRun.INSTANCE.cycleDistance) == 0) {
            currentColor = new CustomColor(nextColor);
            if (!colorIterator.hasNext()) {
                colorIterator = COLORS.iterator();
            }
            nextColor = colorIterator.next();
            changeRed = (nextColor.r - currentColor.r) / (sampleRate * MapConfig.LootRun.INSTANCE.cycleDistance);
            changeGreen = (nextColor.g - currentColor.g) / (sampleRate * MapConfig.LootRun.INSTANCE.cycleDistance);
            changeBlue = (nextColor.b - currentColor.b) / (sampleRate * MapConfig.LootRun.INSTANCE.cycleDistance);
        } else {
            currentColor = new CustomColor(currentColor);
            currentColor.r += changeRed;
            currentColor.g += changeGreen;
            currentColor.b += changeBlue;
        }
        LootRunPathLocation location = new LootRunPathLocation(rawLocations.get(i), currentColor);
        locations.add(location);
    }
    List<LootRunPath.LootRunPathLocation> locationsSample = locations;
    List<Vector3d> derivative = sample.b;
    return new Pair<>(locationsSample, derivative);
}
Also used : Vector3d(javax.vecmath.Vector3d) CustomColor(com.wynntils.core.framework.rendering.colors.CustomColor) Location(com.wynntils.core.utils.objects.Location) Pair(com.wynntils.core.utils.objects.Pair)

Example 2 with Location

use of com.wynntils.core.utils.objects.Location in project Wynntils by Wynntils.

the class LootRunManager method recordMovement.

public static void recordMovement(double x, double y, double z) {
    if (!isRecording())
        return;
    Location to = new Location(x, y + .25d, z);
    if (recordingPath.isEmpty()) {
        recordingPath.addPoint(to);
        return;
    }
    if (recordingPath.getLastPoint().distanceSquared(to) < 4d)
        return;
    recordingPath.addPoint(to);
}
Also used : Location(com.wynntils.core.utils.objects.Location)

Example 3 with Location

use of com.wynntils.core.utils.objects.Location in project Wynntils by Wynntils.

the class LootRunManager method undoMovement.

public static boolean undoMovement(double x, double y, double z) {
    if (!isRecording())
        return false;
    Location to = new Location(x, y + .25d, z);
    List<Location> recordedPoints = recordingPath.getPoints();
    List<Location> removed = new ArrayList<>();
    boolean pastInitial = false;
    for (int i = recordedPoints.size() - 1; i >= 0; i--) {
        // never found a point to rewind to
        if (i == 0)
            return false;
        if (recordedPoints.get(i).distanceSquared(to) < 4d) {
            // we've reached the player again
            if (pastInitial)
                break;
        } else {
            // we've moved past the end of the path
            if (!pastInitial)
                pastInitial = true;
        }
        removed.add(recordedPoints.get(i));
    }
    recordingPath.removePoints(removed);
    return true;
}
Also used : ArrayList(java.util.ArrayList) Location(com.wynntils.core.utils.objects.Location)

Example 4 with Location

use of com.wynntils.core.utils.objects.Location in project Wynntils by Wynntils.

the class DiscoveriesPage method handleEntryClick.

@Override
protected void handleEntryClick(DiscoveryInfo itemInfo, int mouseButton) {
    if (selectedEntry.getType() == DiscoveryType.SECRET) {
        // Secret discovery actions
        String name = TextFormatting.getTextWithoutFormattingCodes(selectedEntry.getName());
        switch(mouseButton) {
            case // Left Click
            0:
                if (QuestBookConfig.INSTANCE.spoilSecretDiscoveries.followsRule(selectedEntry.wasDiscovered())) {
                    locateSecretDiscovery(name, "compass");
                    McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_ANVIL_PLACE, 1f));
                }
                break;
            case // Right Click
            1:
                if (QuestBookConfig.INSTANCE.spoilSecretDiscoveries.followsRule(selectedEntry.wasDiscovered())) {
                    locateSecretDiscovery(name, "map");
                    McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1f));
                }
                break;
            case // Middle Click
            2:
                String wikiUrl = "https://wynncraft.fandom.com/wiki/" + Utils.encodeForWikiTitle(name);
                Utils.openUrl(wikiUrl);
                McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1f));
                break;
        }
    } else if (selectedEntry.getGuildTerritoryProfile() != null) {
        // Guild territory actions
        TerritoryProfile guildTerritory = selectedEntry.getGuildTerritoryProfile();
        int x = (guildTerritory.getStartX() + guildTerritory.getEndX()) / 2;
        int z = (guildTerritory.getStartZ() + guildTerritory.getEndZ()) / 2;
        switch(mouseButton) {
            case // Left Click
            0:
                CompassManager.setCompassLocation(new Location(x, 50, z));
                McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_ANVIL_PLACE, 1f));
                break;
            case // Right Click
            1:
                Utils.displayGuiScreen(new MainWorldMapUI(x, z));
                McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1f));
                break;
            case // Middle Click
            2:
                Utils.displayGuiScreen(new MainWorldMapUI(x, z));
                CompassManager.setCompassLocation(new Location(x, 50, z));
                McIf.mc().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1f));
                break;
        }
    }
}
Also used : TerritoryProfile(com.wynntils.webapi.profiles.TerritoryProfile) MainWorldMapUI(com.wynntils.modules.map.overlays.ui.MainWorldMapUI) TextComponentString(net.minecraft.util.text.TextComponentString) Location(com.wynntils.core.utils.objects.Location)

Example 5 with Location

use of com.wynntils.core.utils.objects.Location in project Wynntils by Wynntils.

the class CommandLocate method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        throw new WrongUsageException("/" + getUsage(sender));
    }
    List<LocationProfile> knownProfiles = mapFeatures.get(args[0]);
    if (knownProfiles == null) {
        // Try case insensitive search
        Optional<String> match = mapFeatures.keySet().stream().filter(key -> key.toLowerCase().equals(args[0].toLowerCase())).findFirst();
        if (!match.isPresent()) {
            throw new WrongUsageException("Unknown map feature: " + args[0]);
        } else {
            knownProfiles = mapFeatures.get(match.get());
        }
    }
    Map<Double, LocationProfile> distanceToLocations = new TreeMap<>();
    Location currentLocation = new Location(McIf.player());
    for (LocationProfile locationProfile : knownProfiles) {
        Location location = new Location(locationProfile.getX(), currentLocation.getY(), locationProfile.getZ());
        double distance = location.distance(currentLocation);
        distanceToLocations.put(distance, locationProfile);
    }
    int numPrinted = 0;
    for (Map.Entry<Double, LocationProfile> entry : distanceToLocations.entrySet()) {
        double distance = entry.getKey();
        LocationProfile mmp = entry.getValue();
        ITextComponent startingPointMsg = new TextComponentString(mmp.getTranslatedName() + " is located at [" + mmp.getX() + ", " + mmp.getZ() + "] (" + (int) distance + " blocks)");
        startingPointMsg.getStyle().setColor(GRAY);
        sender.sendMessage(startingPointMsg);
        numPrinted++;
        if (numPrinted >= 3)
            break;
    }
}
Also used : java.util(java.util) McIf(com.wynntils.McIf) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) LocationProfile(com.wynntils.webapi.profiles.LocationProfile) ITextComponent(net.minecraft.util.text.ITextComponent) GRAY(net.minecraft.util.text.TextFormatting.GRAY) TextComponentString(net.minecraft.util.text.TextComponentString) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Location(com.wynntils.core.utils.objects.Location) Minecraft(net.minecraft.client.Minecraft) ICommandSender(net.minecraft.command.ICommandSender) WrongUsageException(net.minecraft.command.WrongUsageException) WebManager(com.wynntils.webapi.WebManager) IClientCommand(net.minecraftforge.client.IClientCommand) ITextComponent(net.minecraft.util.text.ITextComponent) LocationProfile(com.wynntils.webapi.profiles.LocationProfile) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) WrongUsageException(net.minecraft.command.WrongUsageException) Location(com.wynntils.core.utils.objects.Location)

Aggregations

Location (com.wynntils.core.utils.objects.Location)34 TextComponentString (net.minecraft.util.text.TextComponentString)8 Matcher (java.util.regex.Matcher)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)7 Entity (net.minecraft.entity.Entity)5 BlockPos (net.minecraft.util.math.BlockPos)5 McIf (com.wynntils.McIf)4 MainWorldMapUI (com.wynntils.modules.map.overlays.ui.MainWorldMapUI)4 WebManager (com.wynntils.webapi.WebManager)4 IOException (java.io.IOException)4 CommandException (net.minecraft.command.CommandException)4 WrongUsageException (net.minecraft.command.WrongUsageException)4 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)3 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ScreenRenderer (com.wynntils.core.framework.rendering.ScreenRenderer)2 SmartFontRenderer (com.wynntils.core.framework.rendering.SmartFontRenderer)2 CommonColors (com.wynntils.core.framework.rendering.colors.CommonColors)2 CustomColor (com.wynntils.core.framework.rendering.colors.CustomColor)2