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);
}
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);
}
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;
}
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;
}
}
}
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;
}
}
Aggregations