From 5aa75daf25d24a581889c6b5a97bec3fb6e3dff8 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 10:43:35 -0400 Subject: [PATCH 01/18] Add ordered waypoints gui --- .../skyblock/waypoint/OrderedWaypoints.java | 16 ++- .../waypoint/WaypointsListWidget.java | 19 ++- .../skyblock/waypoint/WaypointsScreen.java | 4 +- .../waypoint/WaypointsShareScreen.java | 2 +- .../utils/waypoint/NamedWaypoint.java | 39 +++--- .../utils/waypoint/OrderedNamedWaypoint.java | 85 ++++++++++++ .../utils/waypoint/ProfileAwareWaypoint.java | 2 +- .../skyblocker/utils/waypoint/Waypoint.java | 48 ++++--- .../utils/waypoint/WaypointCategory.java | 130 ++++++++++++++++-- .../waypoint/ProfileAwareWaypointTest.java | 8 +- 10 files changed, 290 insertions(+), 63 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index 34c3a16b6c..d62cefdb74 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -66,7 +66,7 @@ public class OrderedWaypoints { private static final Map WAYPOINTS = new Object2ObjectOpenHashMap<>(); private static final Semaphore SEMAPHORE = new Semaphore(1); private static final Object2IntOpenHashMap INDEX_STORE = new Object2IntOpenHashMap<>(); - private static final int RADIUS = 2; + public static final int RADIUS = 2; private static final float[] LIGHT_GRAY = { 192 / 255f, 192 / 255f, 192 / 255f }; private static CompletableFuture loaded; @@ -399,10 +399,11 @@ private BlockPos getPos() { } @Override - public float[] getColorComponents() { + public float[] getRenderColorComponents() { if (this.colorComponents.length != 3) { return switch (this.relativeIndex) { - case PREVIOUS -> RED; + case NONE -> this.colorComponents; + case PREVIOUS -> RED; case CURRENT -> WHITE; case NEXT -> GREEN; }; @@ -445,9 +446,14 @@ record Options(Optional name) { } } - private enum RelativeIndex { + public enum RelativeIndex { + NONE, PREVIOUS, CURRENT, - NEXT + NEXT; + + public boolean shouldRender() { + return this != NONE; + } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java index 99716bc4da..4effc5a548 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java @@ -105,6 +105,7 @@ protected class WaypointCategoryEntry extends AbstractWaypointEntry { private final List children; private final CheckboxWidget enabled; private final TextFieldWidget nameField; + private final CheckboxWidget ordered; private final ButtonWidget buttonNewWaypoint; private final ButtonWidget buttonDelete; @@ -118,6 +119,7 @@ public WaypointCategoryEntry(WaypointCategory category) { nameField = new TextFieldWidget(client.textRenderer, 70, 20, Text.literal("Name")); nameField.setText(category.name()); nameField.setChangedListener(this::updateName); + ordered = CheckboxWidget.builder(Text.literal("Ordered"), client.textRenderer).checked(category.ordered()).callback((checkbox, checked) -> updateOrdered(checked)).build(); buttonNewWaypoint = ButtonWidget.builder(Text.translatable("skyblocker.waypoints.new"), buttonNewWaypoint -> { WaypointEntry waypointEntry = new WaypointEntry(this); int entryIndex; @@ -140,7 +142,7 @@ public WaypointCategoryEntry(WaypointCategory category) { WaypointsListWidget.this.children().remove(this); waypoints.remove(category); }).width(38).build(); - children = List.of(enabled, nameField, buttonNewWaypoint, buttonDelete); + children = List.of(enabled, nameField, ordered, buttonNewWaypoint, buttonDelete); } @Override @@ -165,10 +167,19 @@ private void updateName(String name) { } } + private void updateOrdered(boolean ordered) { + int index = waypoints.indexOf(category); + category = category.withOrdered(ordered); + if (index >= 0) { + waypoints.set(index, category); + } + } + @Override public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { enabled.setPosition(x, y + 1); nameField.setPosition(x + 22, y); + ordered.setPosition(x + entryWidth - 190, y + 1); buttonNewWaypoint.setPosition(x + entryWidth - 115, y); buttonDelete.setPosition(x + entryWidth - 38, y); for (ClickableWidget child : children) { @@ -190,7 +201,7 @@ protected class WaypointEntry extends AbstractWaypointEntry { private final ButtonWidget buttonDelete; public WaypointEntry(WaypointCategoryEntry category) { - this(category, new NamedWaypoint(getDefaultPos(), "New Waypoint", new float[]{0f, 1f, 0f})); + this(category, category.category.createWaypoint(getDefaultPos())); } public WaypointEntry(WaypointCategoryEntry category, NamedWaypoint waypoint) { @@ -213,7 +224,7 @@ public WaypointEntry(WaypointCategoryEntry category, NamedWaypoint waypoint) { zField.setTextPredicate(this::checkInt); zField.setChangedListener(this::updateZ); colorField = new TextFieldWidget(client.textRenderer, 56, 20, Text.literal("Color")); - colorField.setText(String.format("%02X%02X%02X%02X", (int) (waypoint.alpha * 255), (int) (waypoint.getColorComponents()[0] * 255), (int) (waypoint.getColorComponents()[1] * 255), (int) (waypoint.getColorComponents()[2] * 255))); + colorField.setText(String.format("%02X%02X%02X%02X", (int) (waypoint.alpha * 255), (int) (waypoint.colorComponents[0] * 255), (int) (waypoint.colorComponents[1] * 255), (int) (waypoint.colorComponents[2] * 255))); colorField.setChangedListener(this::updateColor); buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.deleteButton"), button -> { category.category.waypoints().remove(waypoint); @@ -282,7 +293,7 @@ private void updateColor(String colorString) { int colorInt = parseEmptiableInt(colorString, 16); float[] colorComponents = {((colorInt & 0x00FF0000) >> 16) / 255f, ((colorInt & 0x0000FF00) >> 8) / 255f, (colorInt & 0x000000FF) / 255f}; float alpha = ((colorInt & 0xFF000000) >>> 24) / 255f; - if (Arrays.equals(waypoint.getColorComponents(), colorComponents) && waypoint.alpha == alpha) return; + if (Arrays.equals(waypoint.colorComponents, colorComponents) && waypoint.alpha == alpha) return; waypoint = waypoint.withColor(colorComponents, alpha); if (index >= 0) { category.category.waypoints().set(index, waypoint); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java index 23a2436189..f5d39834dd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java @@ -45,12 +45,12 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { @Override protected boolean isEnabled(NamedWaypoint waypoint) { - return waypoint.shouldRender(); + return waypoint.isEnabled(); } @Override protected void enabledChanged(NamedWaypoint waypoint, boolean enabled) { - waypoint.setShouldRender(enabled); + waypoint.setEnabled(enabled); } private void saveWaypoints() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index eaca845a78..3e6a1cf2c6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -48,7 +48,7 @@ protected void init() { adder.add(ButtonWidget.builder(ScreenTexts.BACK, buttonBack -> close()).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils"), buttonExport -> { try { - List waypointCategories = waypoints.values().stream().filter(waypointCategory -> waypointCategory.island().equals(island)).map(WaypointCategory.filter(selectedWaypoints::contains)).filter(waypointCategory -> !waypointCategory.waypoints().isEmpty()).toList(); + List waypointCategories = waypoints.values().stream().filter(waypointCategory -> waypointCategory.island().equals(island)).map(waypointCategory -> waypointCategory.filterWaypoints(selectedWaypoints::contains)).filter(waypointCategory -> !waypointCategory.waypoints().isEmpty()).toList(); client.keyboard.setClipboard(Waypoints.toSkytilsBase64(waypointCategories)); SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointCategories.stream().map(WaypointCategory::waypoints).mapToInt(List::size).sum(), waypointCategories.size())); } catch (Exception e) { diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index d6b6d5856b..5bc7746222 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -27,7 +27,7 @@ public class NamedWaypoint extends Waypoint { Floats::asList ).fieldOf("colorComponents").forGetter(secretWaypoint -> secretWaypoint.colorComponents), Codec.FLOAT.fieldOf("alpha").forGetter(secretWaypoint -> secretWaypoint.alpha), - Codec.BOOL.fieldOf("shouldRender").forGetter(Waypoint::shouldRender) + Codec.BOOL.fieldOf("shouldRender").forGetter(Waypoint::isEnabled) ).apply(instance, NamedWaypoint::new)); public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.INT.fieldOf("x").forGetter(waypoint -> waypoint.pos.getX()), @@ -35,33 +35,37 @@ public class NamedWaypoint extends Waypoint { Codec.INT.fieldOf("z").forGetter(waypoint -> waypoint.pos.getZ()), Codec.either(Codec.STRING, Codec.INT).xmap(either -> either.map(str -> str, Object::toString), Either::left).fieldOf("name").forGetter(waypoint -> waypoint.name.getString()), Codec.INT.optionalFieldOf("color", ColorHelper.getArgb(128, 0, 255, 0)).forGetter(waypoint -> (int) (waypoint.alpha * 255) << 24 | (int) (waypoint.colorComponents[0] * 255) << 16 | (int) (waypoint.colorComponents[1] * 255) << 8 | (int) (waypoint.colorComponents[2] * 255)), - Codec.BOOL.fieldOf("enabled").forGetter(Waypoint::shouldRender) + Codec.BOOL.fieldOf("enabled").forGetter(Waypoint::isEnabled) ).apply(instance, NamedWaypoint::fromSkytils)); public final Text name; public final Vec3d centerPos; + public NamedWaypoint(NamedWaypoint namedWaypoint) { + this(namedWaypoint.pos, namedWaypoint.name, namedWaypoint.typeSupplier, namedWaypoint.colorComponents, namedWaypoint.alpha, namedWaypoint.isEnabled()); + } + public NamedWaypoint(BlockPos pos, String name, float[] colorComponents) { this(pos, name, colorComponents, true); } - public NamedWaypoint(BlockPos pos, String name, float[] colorComponents, boolean shouldRender) { - this(pos, name, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, shouldRender); + public NamedWaypoint(BlockPos pos, String name, float[] colorComponents, boolean enabled) { + this(pos, name, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, enabled); } - public NamedWaypoint(BlockPos pos, String name, float[] colorComponents, float alpha, boolean shouldRender) { - this(pos, Text.of(name), colorComponents, alpha, shouldRender); + public NamedWaypoint(BlockPos pos, String name, float[] colorComponents, float alpha, boolean enabled) { + this(pos, Text.of(name), colorComponents, alpha, enabled); } - public NamedWaypoint(BlockPos pos, Text name, float[] colorComponents, float alpha, boolean shouldRender) { - this(pos, name, () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents, alpha, shouldRender); + public NamedWaypoint(BlockPos pos, Text name, float[] colorComponents, float alpha, boolean enabled) { + this(pos, name, () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents, alpha, enabled); } public NamedWaypoint(BlockPos pos, Text name, Supplier typeSupplier, float[] colorComponents) { this(pos, name, typeSupplier, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, true); } - public NamedWaypoint(BlockPos pos, Text name, Supplier typeSupplier, float[] colorComponents, float alpha, boolean shouldRender) { - super(pos, typeSupplier, colorComponents, alpha, DEFAULT_LINE_WIDTH, true, shouldRender); + public NamedWaypoint(BlockPos pos, Text name, Supplier typeSupplier, float[] colorComponents, float alpha, boolean enabled) { + super(pos, typeSupplier, colorComponents, alpha, DEFAULT_LINE_WIDTH, true, enabled); this.name = name; this.centerPos = pos.toCenterPos(); } @@ -74,28 +78,31 @@ public static NamedWaypoint fromSkytils(int x, int y, int z, String name, int co return new NamedWaypoint(new BlockPos(x, y, z), name, ColorUtils.getFloatComponents(color), alpha, enabled); } + /** + * Returns a copy of this waypoint. Note that this differs from {@link #NamedWaypoint(NamedWaypoint) the copy constructor} in that this should be overridden by subclasses and return a new instance of the runtime type. + */ public NamedWaypoint copy() { - return new NamedWaypoint(pos, name, typeSupplier, getColorComponents(), alpha, shouldRender()); + return new NamedWaypoint(pos, name, typeSupplier, colorComponents, alpha, isEnabled()); } @Override public NamedWaypoint withX(int x) { - return new NamedWaypoint(new BlockPos(x, pos.getY(), pos.getZ()), name, typeSupplier, getColorComponents(), alpha, shouldRender()); + return new NamedWaypoint(new BlockPos(x, pos.getY(), pos.getZ()), name, typeSupplier, colorComponents, alpha, isEnabled()); } @Override public NamedWaypoint withY(int y) { - return new NamedWaypoint(pos.withY(y), name, typeSupplier, getColorComponents(), alpha, shouldRender()); + return new NamedWaypoint(pos.withY(y), name, typeSupplier, colorComponents, alpha, isEnabled()); } @Override public NamedWaypoint withZ(int z) { - return new NamedWaypoint(new BlockPos(pos.getX(), pos.getY(), z), name, typeSupplier, getColorComponents(), alpha, shouldRender()); + return new NamedWaypoint(new BlockPos(pos.getX(), pos.getY(), z), name, typeSupplier, colorComponents, alpha, isEnabled()); } @Override public NamedWaypoint withColor(float[] colorComponents, float alpha) { - return new NamedWaypoint(pos, name, typeSupplier, colorComponents, alpha, shouldRender()); + return new NamedWaypoint(pos, name, typeSupplier, colorComponents, alpha, isEnabled()); } public Text getName() { @@ -103,7 +110,7 @@ public Text getName() { } public NamedWaypoint withName(String name) { - return new NamedWaypoint(pos, Text.literal(name), typeSupplier, getColorComponents(), alpha, shouldRender()); + return new NamedWaypoint(pos, Text.literal(name), typeSupplier, colorComponents, alpha, isEnabled()); } protected boolean shouldRenderName() { diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java new file mode 100644 index 0000000000..9fa86f44ce --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java @@ -0,0 +1,85 @@ +package de.hysky.skyblocker.utils.waypoint; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; + +import java.util.function.Supplier; + +public class OrderedNamedWaypoint extends NamedWaypoint { + private static final float[] RED_COLOR_COMPONENTS = {1f, 0f, 0f}; + private static final float[] WHITE_COLOR_COMPONENTS = {1f, 1f, 1f}; + private static final float[] GREEN_COLOR_COMPONENTS = {0f, 1f, 0f}; + + int index; + OrderedWaypoints.RelativeIndex relativeIndex; + + public OrderedNamedWaypoint(NamedWaypoint namedWaypoint) { + this(namedWaypoint.pos, namedWaypoint.name, namedWaypoint.typeSupplier, namedWaypoint.colorComponents, namedWaypoint.alpha, namedWaypoint.isEnabled()); + } + + public OrderedNamedWaypoint(BlockPos pos, String name, float[] colorComponents) { + this(pos, Text.of(name), () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, true); + } + + public OrderedNamedWaypoint(BlockPos pos, Text name, Supplier typeSupplier, float[] colorComponents, float alpha, boolean shouldRender) { + super(pos, name, typeSupplier, colorComponents, alpha, shouldRender); + } + + @Override + public OrderedNamedWaypoint copy() { + return new OrderedNamedWaypoint(this); + } + + @Override + public OrderedNamedWaypoint withX(int x) { + return new OrderedNamedWaypoint(new BlockPos(x, pos.getY(), pos.getZ()), name, typeSupplier, colorComponents, alpha, isEnabled()); + } + + @Override + public OrderedNamedWaypoint withY(int y) { + return new OrderedNamedWaypoint(new BlockPos(pos.getX(), y, pos.getZ()), name, typeSupplier, colorComponents, alpha, isEnabled()); + } + + @Override + public OrderedNamedWaypoint withZ(int z) { + return new OrderedNamedWaypoint(new BlockPos(pos.getX(), pos.getY(), z), name, typeSupplier, colorComponents, alpha, isEnabled()); + } + + @Override + public OrderedNamedWaypoint withColor(float[] colorComponents, float alpha) { + return new OrderedNamedWaypoint(pos, name, typeSupplier, colorComponents, alpha, isEnabled()); + } + + @Override + public OrderedNamedWaypoint withName(String name) { + return new OrderedNamedWaypoint(pos, Text.of(name), typeSupplier, colorComponents, alpha, isEnabled()); + } + + @Override + public boolean shouldRender() { + return super.shouldRender() && relativeIndex.shouldRender(); + } + + @Override + public float[] getRenderColorComponents() { + return switch (relativeIndex) { + case NONE -> super.getRenderColorComponents(); + case PREVIOUS -> RED_COLOR_COMPONENTS; + case CURRENT -> WHITE_COLOR_COMPONENTS; + case NEXT -> GREEN_COLOR_COMPONENTS; + }; + } + + @Override + public void render(WorldRenderContext context) { + super.render(context); + if (shouldRenderName()) { + RenderHelper.renderText(context, Text.of(String.valueOf(index)), centerPos.add(0, 1, 0), 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java index 7369a2efc4..7670eb3317 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypoint.java @@ -38,7 +38,7 @@ public void setMissing() { } @Override - public float[] getColorComponents() { + public float[] getRenderColorComponents() { return foundProfiles.contains(Utils.getProfile()) ? foundColor : missingColor; } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java index da927cb7f4..36776ee055 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -18,11 +18,11 @@ public class Waypoint implements Renderable { public final BlockPos pos; final Box box; final Supplier typeSupplier; - protected final float[] colorComponents; + public final float[] colorComponents; public final float alpha; public final float lineWidth; public final boolean throughWalls; - private boolean shouldRender; + private boolean enabled; public Waypoint(BlockPos pos, Type type, float[] colorComponents) { this(pos, type, colorComponents, DEFAULT_HIGHLIGHT_ALPHA); @@ -48,7 +48,7 @@ public Waypoint(BlockPos pos, Supplier typeSupplier, float[] colorComponen this(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, true); } - public Waypoint(BlockPos pos, Supplier typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls, boolean shouldRender) { + public Waypoint(BlockPos pos, Supplier typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls, boolean enabled) { this.pos = pos; this.box = new Box(pos); this.typeSupplier = typeSupplier; @@ -56,76 +56,80 @@ public Waypoint(BlockPos pos, Supplier typeSupplier, float[] colorComponen this.alpha = alpha; this.lineWidth = lineWidth; this.throughWalls = throughWalls; - this.shouldRender = shouldRender; + this.enabled = enabled; } public Waypoint withX(int x) { - return new Waypoint(new BlockPos(x, pos.getY(), pos.getZ()), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + return new Waypoint(new BlockPos(x, pos.getY(), pos.getZ()), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } public Waypoint withY(int y) { - return new Waypoint(pos.withY(y), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + return new Waypoint(pos.withY(y), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } public Waypoint withZ(int z) { - return new Waypoint(new BlockPos(pos.getX(), pos.getY(), z), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + return new Waypoint(new BlockPos(pos.getX(), pos.getY(), z), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } public Waypoint withColor(float[] colorComponents, float alpha) { - return new Waypoint(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, shouldRender()); + return new Waypoint(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } public boolean shouldRender() { - return shouldRender; + return enabled; } public void setFound() { - this.shouldRender = false; + this.enabled = false; } public void setMissing() { - this.shouldRender = true; + this.enabled = true; } public void toggle() { - this.shouldRender = !this.shouldRender; + this.enabled = !this.enabled; } - public void setShouldRender(boolean shouldRender) { - this.shouldRender = shouldRender; + public final boolean isEnabled() { + return enabled; } - public float[] getColorComponents() { + public final void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public float[] getRenderColorComponents() { return colorComponents; } @Override public void render(WorldRenderContext context) { switch (typeSupplier.get()) { - case WAYPOINT -> RenderHelper.renderFilledWithBeaconBeam(context, pos, getColorComponents(), alpha, throughWalls); + case WAYPOINT -> RenderHelper.renderFilledWithBeaconBeam(context, pos, getRenderColorComponents(), alpha, throughWalls); case OUTLINED_WAYPOINT -> { - float[] colorComponents = getColorComponents(); + float[] colorComponents = getRenderColorComponents(); RenderHelper.renderFilledWithBeaconBeam(context, pos, colorComponents, alpha, throughWalls); RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls); } - case HIGHLIGHT -> RenderHelper.renderFilled(context, pos, getColorComponents(), alpha, throughWalls); + case HIGHLIGHT -> RenderHelper.renderFilled(context, pos, getRenderColorComponents(), alpha, throughWalls); case OUTLINED_HIGHLIGHT -> { - float[] colorComponents = getColorComponents(); + float[] colorComponents = getRenderColorComponents(); RenderHelper.renderFilled(context, pos, colorComponents, alpha, throughWalls); RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls); } - case OUTLINE -> RenderHelper.renderOutline(context, box, getColorComponents(), lineWidth, throughWalls); + case OUTLINE -> RenderHelper.renderOutline(context, box, getRenderColorComponents(), lineWidth, throughWalls); } } @Override public int hashCode() { - return Objects.hash(pos, typeSupplier.get(), Arrays.hashCode(colorComponents), alpha, lineWidth, throughWalls, shouldRender); + return Objects.hash(pos, typeSupplier.get(), Arrays.hashCode(colorComponents), alpha, lineWidth, throughWalls, enabled); } @Override public boolean equals(Object obj) { - return super.equals(obj) || obj instanceof Waypoint other && pos.equals(other.pos) && typeSupplier.get() == other.typeSupplier.get() && Arrays.equals(colorComponents, other.colorComponents) && alpha == other.alpha && lineWidth == other.lineWidth && throughWalls == other.throughWalls && shouldRender == other.shouldRender; + return super.equals(obj) || obj instanceof Waypoint other && pos.equals(other.pos) && typeSupplier.get() == other.typeSupplier.get() && Arrays.equals(colorComponents, other.colorComponents) && alpha == other.alpha && lineWidth == other.lineWidth && throughWalls == other.throughWalls && enabled == other.enabled; } public enum Type implements StringIdentifiable { diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java index 8bfef7f46f..eecb28a742 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java @@ -2,18 +2,23 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.math.BlockPos; import java.util.List; +import java.util.Objects; import java.util.function.Predicate; -import java.util.function.UnaryOperator; import java.util.stream.Collectors; -public record WaypointCategory(String name, String island, List waypoints) { +public class WaypointCategory { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("name").forGetter(WaypointCategory::name), Codec.STRING.fieldOf("island").forGetter(WaypointCategory::island), - NamedWaypoint.CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints) + NamedWaypoint.CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints), + Codec.BOOL.lenientOptionalFieldOf("ordered", false).forGetter(WaypointCategory::ordered), + Codec.INT.lenientOptionalFieldOf("currentIndex", 0).forGetter(category -> category.currentIndex) ).apply(instance, WaypointCategory::new)); public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("name").forGetter(WaypointCategory::name), @@ -21,27 +26,136 @@ public record WaypointCategory(String name, String island, List w NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints) ).apply(instance, WaypointCategory::new)); - public static UnaryOperator filter(Predicate predicate) { - return waypointCategory -> new WaypointCategory(waypointCategory.name(), waypointCategory.island(), waypointCategory.waypoints().stream().filter(predicate).toList()); + private final String name; + private final String island; + private final List waypoints; + private final boolean ordered; + protected int currentIndex; + + public WaypointCategory(String name, String island, List waypoints) { + this(name, island, waypoints, false, 0); + } + + public WaypointCategory(String name, String island, List waypoints, boolean ordered, int currentIndex) { + this.name = name; + this.island = island; + // Set ordered first since convertWaypoint depends on it + this.ordered = ordered; + this.waypoints = waypoints.stream().map(this::convertWaypoint).collect(Collectors.toList()); + this.currentIndex = currentIndex; + } + + public String name() { + return name; + } + + public String island() { + return island; + } + + public List waypoints() { + return waypoints; + } + + public boolean ordered() { + return ordered; } public WaypointCategory withName(String name) { - return new WaypointCategory(name, island(), waypoints()); + return new WaypointCategory(name, island, waypoints, ordered, currentIndex); } public WaypointCategory withIsland(String island) { - return new WaypointCategory(name(), island, waypoints()); + return new WaypointCategory(name, island, waypoints, ordered, currentIndex); + } + + public WaypointCategory withOrdered(boolean ordered) { + return new WaypointCategory(name, island, waypoints, ordered, currentIndex); + } + + public WaypointCategory filterWaypoints(Predicate predicate) { + return new WaypointCategory(name, island, waypoints.stream().filter(predicate).toList(), ordered, currentIndex); } + /** + * Returns a deep copy of this {@link WaypointCategory} with a mutable waypoints list for editing. + */ public WaypointCategory deepCopy() { - return new WaypointCategory(name(), island(), waypoints().stream().map(NamedWaypoint::copy).collect(Collectors.toList())); + return new WaypointCategory(name, island, waypoints.stream().map(NamedWaypoint::copy).collect(Collectors.toList()), ordered, currentIndex); + } + + public NamedWaypoint createWaypoint(BlockPos pos) { + String name = "Waypoint " + (waypoints.size() + 1); + return ordered ? new OrderedNamedWaypoint(pos, name, new float[]{0f, 1f, 0f}) : new NamedWaypoint(pos, name, new float[]{0f, 1f, 0f}); + } + + /** + * Converts the given waypoint to the correct type based on whether this category is ordered or not. + */ + public NamedWaypoint convertWaypoint(NamedWaypoint waypoint) { + if (ordered) { + return waypoint instanceof OrderedNamedWaypoint ? waypoint : new OrderedNamedWaypoint(waypoint); + } else { + return waypoint instanceof OrderedNamedWaypoint ? new NamedWaypoint(waypoint) : waypoint; + } } public void render(WorldRenderContext context) { + if (ordered) { + for (int i = 0; i < waypoints.size(); i++) { + NamedWaypoint waypoint = waypoints.get(i); + if (waypoint.pos.isWithinDistance(MinecraftClient.getInstance().player.getPos(), OrderedWaypoints.RADIUS)) { + currentIndex = i; + } + } + + int categoryPreviousIndex = (currentIndex - 1 + waypoints.size()) % waypoints.size(); + int categoryNextIndex = (currentIndex + 1) % waypoints.size(); + for (int i = 0; i < waypoints.size(); i++) { + NamedWaypoint waypoint = waypoints.get(i); + if (waypoint instanceof OrderedNamedWaypoint orderedNamedWaypoint) { + orderedNamedWaypoint.index = i; + if (i == categoryPreviousIndex) { + orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.PREVIOUS; + } else if (i == categoryNextIndex) { + orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.NEXT; + } else if (i == currentIndex) { + orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.CURRENT; + } else { + orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.NONE; + } + } + } + } for (NamedWaypoint waypoint : waypoints) { if (waypoint.shouldRender()) { waypoint.render(context); } } } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (WaypointCategory) obj; + return Objects.equals(this.name, that.name) && + Objects.equals(this.island, that.island) && + Objects.equals(this.waypoints, that.waypoints) && + this.ordered == that.ordered; + } + + @Override + public int hashCode() { + return Objects.hash(name, island, waypoints, ordered); + } + + @Override + public String toString() { + return "WaypointCategory[" + + "name=" + name + ", " + + "island=" + island + ", " + + "waypoints=" + waypoints + ", " + + "ordered=" + ordered + ']'; + } } diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java index 9dc5b2b90a..903920aa1e 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java @@ -17,20 +17,20 @@ void testShouldRender() { } @Test - void testGetColorComponents() { + void testGetRenderColorComponents() { ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, new float[]{0f, 0.5f, 1f}, new float[]{1f, 0.5f, 0f}); waypoint.setFound("profile"); - float[] colorComponents = waypoint.getColorComponents(); + float[] colorComponents = waypoint.getRenderColorComponents(); Assertions.assertEquals(0f, colorComponents[0]); Assertions.assertEquals(0.5f, colorComponents[1]); Assertions.assertEquals(1f, colorComponents[2]); waypoint.setFound(""); - colorComponents = waypoint.getColorComponents(); + colorComponents = waypoint.getRenderColorComponents(); Assertions.assertEquals(1f, colorComponents[0]); Assertions.assertEquals(0.5f, colorComponents[1]); Assertions.assertEquals(0f, colorComponents[2]); waypoint.setMissing(); - colorComponents = waypoint.getColorComponents(); + colorComponents = waypoint.getRenderColorComponents(); Assertions.assertEquals(0f, colorComponents[0]); Assertions.assertEquals(0.5f, colorComponents[1]); Assertions.assertEquals(1f, colorComponents[2]); From 9c7af0d9acb1d1f1ddb066bab3ca2c74f2b8d2f2 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:04:47 -0400 Subject: [PATCH 02/18] Use InstancedUtils --- .../skyblocker/utils/InstancedUtils.java | 5 ++- .../utils/waypoint/WaypointCategory.java | 32 +++++++++-------- .../skyblocker/utils/InstancedUtilsTest.java | 35 ++++++++++--------- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/InstancedUtils.java b/src/main/java/de/hysky/skyblocker/utils/InstancedUtils.java index 1da4fa113a..063240b94c 100644 --- a/src/main/java/de/hysky/skyblocker/utils/InstancedUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/InstancedUtils.java @@ -3,6 +3,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.lang.runtime.ObjectMethods; import java.util.Arrays; import java.util.Map; @@ -92,7 +93,9 @@ private static MethodHandle[] getFieldGetters(Field[] fields) throws Throwable { ObjectOpenHashSet handles = new ObjectOpenHashSet<>(); for (Field field : fields) { - field.setAccessible(true); + if ((field.getModifiers() & Modifier.STATIC) != 0) continue; + + field.setAccessible(true); MethodHandle getter = MethodHandles.lookup().unreflectGetter(field); diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java index eecb28a742..796b8a3e11 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java @@ -3,12 +3,12 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; +import de.hysky.skyblocker.utils.InstancedUtils; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.util.math.BlockPos; import java.util.List; -import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -135,27 +135,29 @@ public void render(WorldRenderContext context) { } @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (obj == null || obj.getClass() != this.getClass()) return false; - var that = (WaypointCategory) obj; - return Objects.equals(this.name, that.name) && - Objects.equals(this.island, that.island) && - Objects.equals(this.waypoints, that.waypoints) && - this.ordered == that.ordered; + public boolean equals(Object o) { + try { + return (boolean) InstancedUtils.equals(getClass()).invokeExact(this, o); + } catch (Throwable ignored) { + return super.equals(o); + } } @Override public int hashCode() { - return Objects.hash(name, island, waypoints, ordered); + try { + return (int) InstancedUtils.hashCode(getClass()).invokeExact(this); + } catch (Throwable ignored) { + return super.hashCode(); + } } @Override public String toString() { - return "WaypointCategory[" + - "name=" + name + ", " + - "island=" + island + ", " + - "waypoints=" + waypoints + ", " + - "ordered=" + ordered + ']'; + try { + return (String) InstancedUtils.toString(getClass()).invokeExact(this); + } catch (Throwable ignored) { + return super.toString(); + } } } diff --git a/src/test/java/de/hysky/skyblocker/utils/InstancedUtilsTest.java b/src/test/java/de/hysky/skyblocker/utils/InstancedUtilsTest.java index e5dbbff698..5f9b8d382d 100644 --- a/src/test/java/de/hysky/skyblocker/utils/InstancedUtilsTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/InstancedUtilsTest.java @@ -5,64 +5,65 @@ public class InstancedUtilsTest { - @Test + @SuppressWarnings("EqualsWithItself") + @Test void testSameInstanceEqual() { Vector3i vec1 = new Vector3i(8, 8, 8); - + Assertions.assertEquals(vec1, vec1); } - + @Test void testSameFieldValuesEqual() { Vector3i vec1 = new Vector3i(8, 8, 8); Vector3i vec2 = new Vector3i(8, 8, 8); - + Assertions.assertEquals(vec1, vec2); } - + @Test void testDifferentFieldValuesEqual() { Vector3i vec1 = new Vector3i(8, 8, 8); Vector3i vec2 = new Vector3i(-8, -8, -8); - + Assertions.assertNotEquals(vec1, vec2); } - + @Test void testHashCodeOfEqualFieldValues() { Vector3i vec1 = new Vector3i(8, 8, 8); Vector3i vec2 = new Vector3i(8, 8, 8); - + Assertions.assertEquals(vec1.hashCode(), vec2.hashCode()); } - + @Test void testHashCodeOfDifferentFieldValues() { Vector3i vec1 = new Vector3i(8, 8, 8); Vector3i vec2 = new Vector3i(-8, -8, -8); - + Assertions.assertNotEquals(vec1.hashCode(), vec2.hashCode()); } - + @Test void testToString() { Vector3i vec1 = new Vector3i(8, 8, 8); - + Assertions.assertEquals(vec1.toString(), "Vector3i[x=8, y=8, z=8]"); } - + @SuppressWarnings("unused") private static class Vector3i { final int x; final int y; final int z; - + Vector3i(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } - + @Override public boolean equals(Object o) { try { @@ -71,7 +72,7 @@ public boolean equals(Object o) { return super.equals(o); } } - + @Override public int hashCode() { try { @@ -80,7 +81,7 @@ public int hashCode() { return System.identityHashCode(this); } } - + @Override public String toString() { try { From 111322652dd2afbd970dd5b0894baba681c32c3b Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 12:09:31 -0400 Subject: [PATCH 03/18] Add fromColeweightJson --- .../skyblock/waypoint/OrderedWaypoints.java | 6 +- .../skyblock/waypoint/Waypoints.java | 9 +- .../utils/waypoint/NamedWaypoint.java | 18 +- .../utils/waypoint/WaypointCategory.java | 7 +- .../utils/waypoint/WaypointCategoryTest.java | 6 +- .../utils/waypoint/WaypointsTest.java | 225 ++++++++++++++++++ 6 files changed, 259 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index d62cefdb74..687c815f08 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -426,7 +426,7 @@ public void render(WorldRenderContext context) { } } - private record ColeWeightWaypoint(OptionalInt x, OptionalInt y, OptionalInt z, OptionalInt r, OptionalInt g, OptionalInt b, Optional options) { + public record ColeWeightWaypoint(OptionalInt x, OptionalInt y, OptionalInt z, OptionalInt r, OptionalInt g, OptionalInt b, Optional options) { static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( CodecUtils.optionalInt(Codec.INT.optionalFieldOf("x")).forGetter(ColeWeightWaypoint::x), CodecUtils.optionalInt(Codec.INT.optionalFieldOf("y")).forGetter(ColeWeightWaypoint::y), @@ -439,8 +439,8 @@ private record ColeWeightWaypoint(OptionalInt x, OptionalInt y, OptionalInt z, O static final Codec> LIST_CODEC = CODEC.listOf(); //Even though we don't import the name this is still here incase that eventually changes - record Options(Optional name) { - static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + public record Options(Optional name) { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.optionalFieldOf("name").forGetter(Options::name)) .apply(instance, Options::new)); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java index 8635d602ad..f02ed91b52 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java @@ -3,10 +3,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.google.common.collect.Multimaps; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; +import com.google.gson.*; import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; @@ -117,6 +114,10 @@ public static String toSkytilsJson(List waypointCategories) { return SkyblockerMod.GSON_COMPACT.toJson(waypointCategoriesJson); } + public static WaypointCategory fromColeweightJson(String waypointsJson, String defaultIsland) { + return WaypointCategory.COLEWEIGHT_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(waypointsJson)).resultOrPartial(LOGGER::error).orElseThrow().withIsland(defaultIsland); + } + public static void saveWaypoints(MinecraftClient client) { try (BufferedWriter writer = Files.newBufferedWriter(waypointsFile)) { JsonElement waypointsJson = CODEC.encodeStart(JsonOps.INSTANCE, List.copyOf(waypoints.values())).resultOrPartial(LOGGER::error).orElseThrow(); diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index 5bc7746222..a199c1bde1 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -6,6 +6,8 @@ import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; +import de.hysky.skyblocker.utils.CodecUtils; import de.hysky.skyblocker.utils.ColorUtils; import de.hysky.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; @@ -15,7 +17,7 @@ import net.minecraft.util.math.ColorHelper; import net.minecraft.util.math.Vec3d; -import java.util.Objects; +import java.util.*; import java.util.function.Supplier; public class NamedWaypoint extends Waypoint { @@ -37,6 +39,15 @@ public class NamedWaypoint extends Waypoint { Codec.INT.optionalFieldOf("color", ColorHelper.getArgb(128, 0, 255, 0)).forGetter(waypoint -> (int) (waypoint.alpha * 255) << 24 | (int) (waypoint.colorComponents[0] * 255) << 16 | (int) (waypoint.colorComponents[1] * 255) << 8 | (int) (waypoint.colorComponents[2] * 255)), Codec.BOOL.fieldOf("enabled").forGetter(Waypoint::isEnabled) ).apply(instance, NamedWaypoint::fromSkytils)); + static final Codec COLEWEIGHT_CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.INT.fieldOf("x").forGetter(waypoint -> waypoint.pos.getX()), + Codec.INT.fieldOf("y").forGetter(waypoint -> waypoint.pos.getY()), + Codec.INT.fieldOf("z").forGetter(waypoint -> waypoint.pos.getZ()), + CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("r")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[0])), + CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("g")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[1])), + CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("b")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[2])), + OrderedWaypoints.ColeWeightWaypoint.Options.CODEC.optionalFieldOf("options").forGetter(waypoint -> Optional.of(new OrderedWaypoints.ColeWeightWaypoint.Options(Optional.of(waypoint.name.getString())))) + ).apply(instance, NamedWaypoint::fromColeweight)); public final Text name; public final Vec3d centerPos; @@ -78,6 +89,11 @@ public static NamedWaypoint fromSkytils(int x, int y, int z, String name, int co return new NamedWaypoint(new BlockPos(x, y, z), name, ColorUtils.getFloatComponents(color), alpha, enabled); } + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + public static NamedWaypoint fromColeweight(int x, int y, int z, OptionalDouble r, OptionalDouble g, OptionalDouble b, Optional options) { + return new NamedWaypoint(new BlockPos(x, y, z), options.flatMap(OrderedWaypoints.ColeWeightWaypoint.Options::name).orElse("New Waypoint"), new float[]{(float) r.orElse(0), (float) g.orElse(1), (float) b.orElse(0)}, DEFAULT_HIGHLIGHT_ALPHA, true); + } + /** * Returns a copy of this waypoint. Note that this differs from {@link #NamedWaypoint(NamedWaypoint) the copy constructor} in that this should be overridden by subclasses and return a new instance of the runtime type. */ diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java index 796b8a3e11..90849b9aca 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java @@ -25,6 +25,7 @@ public class WaypointCategory { Codec.STRING.fieldOf("island").forGetter(WaypointCategory::island), NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints) ).apply(instance, WaypointCategory::new)); + public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointCategory("Coleweight", "", coleWeightWaypoints, true), WaypointCategory::waypoints); private final String name; private final String island; @@ -33,7 +34,11 @@ public class WaypointCategory { protected int currentIndex; public WaypointCategory(String name, String island, List waypoints) { - this(name, island, waypoints, false, 0); + this(name, island, waypoints, false); + } + + public WaypointCategory(String name, String island, List waypoints, boolean ordered) { + this(name, island, waypoints, ordered, 0); } public WaypointCategory(String name, String island, List waypoints, boolean ordered, int currentIndex) { diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java index f9a17bff74..79f0abd41e 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java @@ -22,10 +22,10 @@ static void beforeAll() { @Test void testCodecEncode() { WaypointCategory category = new WaypointCategory("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); - Object categoryJson = WaypointCategory.CODEC.encodeStart(JsonOps.INSTANCE, category).result().orElseThrow(); - String expectedJson = "{\"name\":\"category\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}"; + JsonElement categoryJson = WaypointCategory.CODEC.encodeStart(JsonOps.INSTANCE, category).result().orElseThrow(); + JsonElement expectedJson = SkyblockerMod.GSON.fromJson("{\"name\":\"category\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}", JsonElement.class); - Assertions.assertEquals(expectedJson, categoryJson.toString()); + Assertions.assertEquals(expectedJson, categoryJson); } @Test diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java index cf6f56e9cb..7928bac64c 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java @@ -148,4 +148,229 @@ void testFromSkytilsV1Gzip() { Assertions.assertEquals(expectedWaypointCategories, waypointCategories); } + + @Test + void testFromColeweightJson() { + String coleweightJson = "[{\"x\":64,\"y\":78,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":45,\"y\":79,\"z\":49,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":60,\"y\":76,\"z\":51,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":63,\"y\":76,\"z\":95,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":63,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":94,\"y\":77,\"z\":42,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":91,\"y\":77,\"z\":27,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":50,\"y\":80,\"z\":88,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":50,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":58,\"y\":79,\"z\":89,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":78,\"y\":74,\"z\":99,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":46,\"y\":80,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":97,\"y\":81,\"z\":77,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":55,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":39,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":95,\"y\":76,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":97,\"y\":75,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":45,\"y\":79,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":75,\"y\":82,\"z\":20,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":36,\"y\":80,\"z\":80,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":43,\"y\":77,\"z\":50,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":43,\"y\":79,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":35,\"y\":8,\"z\":71,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":89,\"y\":77,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":73,\"y\":76,\"z\":31,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":47,\"y\":77,\"z\":65,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":52,\"y\":75,\"z\":45,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":82,\"y\":78,\"z\":26,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":61,\"y\":78,\"z\":92,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":73,\"y\":79,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":103,\"y\":74,\"z\":98,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":104,\"y\":78,\"z\":68,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":42,\"y\":77,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":41,\"y\":79,\"z\":81,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":90,\"y\":77,\"z\":46,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":32,\"y\":80,\"z\":74,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":78,\"y\":77,\"z\":40,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":76,\"y\":76,\"z\":55,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":66,\"y\":81,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":90,\"y\":77,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":55,\"y\":80,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":92,\"y\":74,\"z\":108,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":50,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":98,\"y\":77,\"z\":76,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":79,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":91,\"y\":76,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":98,\"y\":78,\"z\":75,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}}]"; + WaypointCategory waypointCategory = Waypoints.fromColeweightJson(coleweightJson, "winter"); + WaypointCategory expectedWaypointCategory = new WaypointCategory("Coleweight", "winter", List.of( + new OrderedNamedWaypoint(new BlockPos(64, 78, 28), "24", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(45, 79, 49), "9", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(60, 76, 51), "20", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(63, 76, 95), "23", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(63, 76, 52), "22", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(94, 77, 42), "40", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(91, 77, 27), "38", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(50, 80, 88), "15", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(50, 79, 34), "14", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(58, 79, 89), "19", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(78, 74, 99), "30", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(46, 80, 84), "11", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(97, 81, 77), "43", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(55, 79, 34), "17", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(39, 80, 73), "4", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(95, 76, 58), "41", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(97, 75, 70), "42", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(45, 79, 70), "10", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(75, 82, 20), "28", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(36, 80, 80), "3", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(43, 77, 50), "7", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(43, 79, 73), "8", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(35, 8, 71), "2", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(89, 77, 84), "34", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(73, 76, 31), "26", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(47, 77, 65), "12", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(52, 75, 45), "16", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(82, 78, 26), "33", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(61, 78, 92), "21", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(73, 79, 52), "27", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(103, 74, 98), "46", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(104, 78, 68), "47", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(42, 77, 58), "6", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(41, 79, 81), "5", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(90, 77, 46), "36", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(32, 80, 74), "1", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(78, 77, 40), "31", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(76, 76, 55), "29", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(66, 81, 28), "25", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(90, 77, 38), "35", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(55, 80, 38), "18", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(92, 74, 108), "39", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(50, 76, 52), "13", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(98, 77, 76), "44", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(79, 80, 73), "32", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(91, 76, 38), "37", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(98, 78, 75), "45", new float[]{0, 1, 0}) + ), true); + + Assertions.assertEquals(expectedWaypointCategory.waypoints().size(), waypointCategory.waypoints().size()); + for (int i = 0; i < waypointCategory.waypoints().size(); i++) { + Assertions.assertEquals(expectedWaypointCategory.waypoints().get(i), waypointCategory.waypoints().get(i)); + } + Assertions.assertEquals(expectedWaypointCategory.name(), waypointCategory.name()); + Assertions.assertEquals(expectedWaypointCategory.island(), waypointCategory.island()); + Assertions.assertEquals(expectedWaypointCategory.ordered(), waypointCategory.ordered()); + Assertions.assertEquals(expectedWaypointCategory, waypointCategory); + } + + @Test + void testFromColeweightJsonSapphire() { + String coleweightJson = "[{\"x\":821,\"y\":137,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":821,\"y\":143,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":812,\"y\":154,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":817,\"y\":159,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":814,\"y\":168,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":814,\"y\":171,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":810,\"y\":177,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":803,\"y\":183,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":802,\"y\":178,\"z\":817,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":803,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":800,\"y\":167,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":787,\"y\":174,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":783,\"y\":177,\"z\":820,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":766,\"y\":177,\"z\":822,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":769,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":775,\"y\":170,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":778,\"y\":161,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":787,\"y\":155,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":778,\"y\":153,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":789,\"y\":154,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":794,\"y\":159,\"z\":823,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":804,\"y\":163,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":794,\"y\":164,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":801,\"y\":168,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":806,\"y\":161,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":801,\"y\":157,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":791,\"y\":161,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":796,\"y\":164,\"z\":776,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":798,\"y\":167,\"z\":774,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":803,\"y\":161,\"z\":764,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":810,\"y\":159,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":817,\"y\":156,\"z\":767,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":821,\"y\":149,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":814,\"y\":139,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":818,\"y\":137,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":818,\"y\":143,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":802,\"y\":140,\"z\":739,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":804,\"y\":131,\"z\":730,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":792,\"y\":121,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":788,\"y\":127,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":792,\"y\":127,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":783,\"y\":123,\"z\":731,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":786,\"y\":122,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":785,\"y\":124,\"z\":707,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":769,\"y\":129,\"z\":709,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}},{\"x\":764,\"y\":131,\"z\":716,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":757,\"y\":131,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":755,\"y\":139,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"48\"}},{\"x\":753,\"y\":134,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"49\"}},{\"x\":768,\"y\":126,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"50\"}},{\"x\":770,\"y\":122,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"51\"}},{\"x\":777,\"y\":116,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"52\"}},{\"x\":779,\"y\":113,\"z\":725,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"53\"}},{\"x\":786,\"y\":116,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"54\"}},{\"x\":783,\"y\":123,\"z\":752,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"55\"}},{\"x\":778,\"y\":125,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"56\"}},{\"x\":784,\"y\":131,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"57\"}},{\"x\":789,\"y\":135,\"z\":760,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"58\"}},{\"x\":792,\"y\":138,\"z\":758,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"59\"}},{\"x\":802,\"y\":138,\"z\":769,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"60\"}},{\"x\":807,\"y\":142,\"z\":780,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"61\"}},{\"x\":805,\"y\":132,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"62\"}},{\"x\":820,\"y\":123,\"z\":772,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"63\"}},{\"x\":813,\"y\":131,\"z\":766,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"64\"}},{\"x\":812,\"y\":127,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"65\"}},{\"x\":804,\"y\":126,\"z\":753,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"66\"}},{\"x\":810,\"y\":125,\"z\":750,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"67\"}},{\"x\":821,\"y\":127,\"z\":751,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"68\"}},{\"x\":815,\"y\":124,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"69\"}},{\"x\":815,\"y\":120,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"70\"}},{\"x\":806,\"y\":115,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"71\"}},{\"x\":796,\"y\":125,\"z\":741,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"72\"}},{\"x\":798,\"y\":119,\"z\":757,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"73\"}},{\"x\":799,\"y\":112,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"74\"}},{\"x\":783,\"y\":110,\"z\":765,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"75\"}},{\"x\":804,\"y\":116,\"z\":777,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"76\"}},{\"x\":801,\"y\":116,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"77\"}},{\"x\":793,\"y\":110,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"78\"}},{\"x\":795,\"y\":107,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"79\"}},{\"x\":805,\"y\":100,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"80\"}},{\"x\":821,\"y\":105,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"81\"}},{\"x\":818,\"y\":96,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"82\"}},{\"x\":803,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"83\"}},{\"x\":793,\"y\":97,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"84\"}},{\"x\":791,\"y\":94,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"85\"}},{\"x\":787,\"y\":94,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"86\"}},{\"x\":775,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"87\"}},{\"x\":771,\"y\":91,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"88\"}},{\"x\":763,\"y\":89,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"89\"}},{\"x\":768,\"y\":101,\"z\":806,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"90\"}},{\"x\":785,\"y\":105,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"91\"}},{\"x\":791,\"y\":101,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"92\"}},{\"x\":791,\"y\":103,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"93\"}},{\"x\":771,\"y\":102,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"94\"}},{\"x\":764,\"y\":99,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"95\"}},{\"x\":758,\"y\":97,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"96\"}},{\"x\":762,\"y\":93,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"97\"}},{\"x\":778,\"y\":92,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"98\"}},{\"x\":786,\"y\":90,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"99\"}},{\"x\":790,\"y\":88,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"100\"}},{\"x\":792,\"y\":82,\"z\":815,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"101\"}},{\"x\":783,\"y\":76,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"102\"}},{\"x\":795,\"y\":69,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"103\"}},{\"x\":800,\"y\":66,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"104\"}},{\"x\":810,\"y\":65,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"105\"}},{\"x\":817,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"106\"}},{\"x\":815,\"y\":75,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"107\"}},{\"x\":822,\"y\":85,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"108\"}},{\"x\":822,\"y\":85,\"z\":785,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"109\"}},{\"x\":811,\"y\":88,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"110\"}},{\"x\":804,\"y\":86,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"111\"}},{\"x\":792,\"y\":78,\"z\":790,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"112\"}},{\"x\":790,\"y\":77,\"z\":793,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"113\"}},{\"x\":785,\"y\":68,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"114\"}},{\"x\":773,\"y\":75,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"115\"}},{\"x\":773,\"y\":78,\"z\":794,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"116\"}},{\"x\":757,\"y\":83,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"117\"}},{\"x\":742,\"y\":84,\"z\":791,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"118\"}},{\"x\":737,\"y\":85,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"119\"}},{\"x\":731,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"120\"}},{\"x\":731,\"y\":81,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"121\"}},{\"x\":743,\"y\":82,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"122\"}},{\"x\":746,\"y\":96,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"123\"}},{\"x\":742,\"y\":110,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"124\"}},{\"x\":745,\"y\":110,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"125\"}},{\"x\":752,\"y\":113,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"126\"}},{\"x\":742,\"y\":123,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"127\"}},{\"x\":736,\"y\":129,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"128\"}},{\"x\":733,\"y\":138,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"129\"}},{\"x\":737,\"y\":134,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"130\"}},{\"x\":741,\"y\":131,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"131\"}},{\"x\":743,\"y\":129,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"132\"}},{\"x\":753,\"y\":134,\"z\":804,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"133\"}},{\"x\":755,\"y\":139,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"134\"}},{\"x\":757,\"y\":131,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"135\"}},{\"x\":772,\"y\":140,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"136\"}},{\"x\":773,\"y\":144,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"137\"}},{\"x\":784,\"y\":142,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"138\"}},{\"x\":785,\"y\":141,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"139\"}},{\"x\":793,\"y\":147,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"140\"}},{\"x\":785,\"y\":137,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"141\"}},{\"x\":790,\"y\":133,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"142\"}},{\"x\":806,\"y\":131,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"143\"}},{\"x\":803,\"y\":131,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"144\"}}]"; + WaypointCategory waypointCategory = Waypoints.fromColeweightJson(coleweightJson, "crystal_hollows"); + WaypointCategory expectedWaypointCategory = new WaypointCategory("Coleweight", "crystal_hollows", List.of( + new OrderedNamedWaypoint(new BlockPos(821, 137, 809), "1", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 143, 809), "2", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(812, 154, 798), "3", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 159, 803), "4", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 168, 798), "5", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 171, 809), "6", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 177, 821), "7", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 183, 821), "8", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 178, 817), "9", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 175, 811), "10", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(800, 167, 799), "11", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 174, 809), "12", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 177, 820), "13", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(766, 177, 822), "14", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(769, 175, 811), "15", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(775, 170, 810), "16", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 161, 800), "17", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 155, 792), "18", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 153, 801), "19", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(789, 154, 809), "20", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(794, 159, 823), "21", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 163, 816), "22", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(794, 164, 800), "23", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 168, 795), "24", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 161, 783), "25", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 157, 778), "26", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 161, 781), "27", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(796, 164, 776), "28", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(798, 167, 774), "29", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 161, 764), "30", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 159, 762), "31", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 156, 767), "32", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 149, 754), "33", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 139, 742), "34", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 137, 736), "35", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 143, 736), "36", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 140, 739), "37", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 131, 730), "38", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 121, 726), "39", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(788, 127, 727), "40", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 127, 726), "41", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 123, 731), "42", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 122, 717), "43", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 124, 707), "44", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(769, 129, 709), "45", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(764, 131, 716), "46", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 131, 717), "47", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(755, 139, 727), "48", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(753, 134, 723), "49", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(768, 126, 723), "50", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(770, 122, 720), "51", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(777, 116, 720), "52", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(779, 113, 725), "53", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 116, 742), "54", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 123, 752), "55", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 125, 762), "56", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(784, 131, 754), "57", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(789, 135, 760), "58", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 138, 758), "59", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 138, 769), "60", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(807, 142, 780), "61", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(805, 132, 775), "62", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(820, 123, 772), "63", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(813, 131, 766), "64", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(812, 127, 763), "65", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 126, 753), "66", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 125, 750), "67", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 127, 751), "68", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 124, 742), "69", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 120, 732), "70", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 115, 732), "71", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(796, 125, 741), "72", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(798, 119, 757), "73", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(799, 112, 763), "74", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 110, 765), "75", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 116, 777), "76", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 116, 788), "77", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 110, 798), "78", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(795, 107, 800), "79", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(805, 100, 803), "80", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 105, 809), "81", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 96, 816), "82", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 92, 802), "83", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 97, 813), "84", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 94, 809), "85", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 94, 810), "86", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(775, 92, 802), "87", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(771, 91, 799), "88", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(763, 89, 805), "89", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(768, 101, 806), "90", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 105, 808), "91", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 101, 805), "92", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 103, 784), "93", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(771, 102, 778), "94", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(764, 99, 781), "95", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(758, 97, 792), "96", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(762, 93, 783), "97", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 92, 775), "98", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 90, 784), "99", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 88, 792), "100", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 82, 815), "101", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 76, 811), "102", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(795, 69, 821), "103", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(800, 66, 807), "104", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 65, 811), "105", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 75, 813), "106", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 75, 800), "107", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(822, 85, 800), "108", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(822, 85, 785), "109", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(811, 88, 778), "110", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 86, 792), "111", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 78, 790), "112", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 77, 793), "113", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 68, 800), "114", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 75, 797), "115", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 78, 794), "116", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 83, 797), "117", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 84, 791), "118", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(737, 85, 797), "119", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(731, 75, 813), "120", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(731, 81, 816), "121", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(743, 82, 821), "122", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(746, 96, 798), "123", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 110, 788), "124", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(745, 110, 807), "125", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(752, 113, 805), "126", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 123, 801), "127", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(736, 129, 801), "128", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(733, 138, 795), "129", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(737, 134, 792), "130", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(741, 131, 799), "131", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(743, 129, 802), "132", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(753, 134, 804), "133", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(755, 139, 808), "134", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 131, 798), "135", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(772, 140, 803), "136", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 144, 797), "137", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(784, 142, 797), "138", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 141, 795), "139", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 147, 801), "140", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 137, 810), "141", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 133, 800), "142", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 131, 803), "143", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 131, 809), "144", new float[]{0, 1, 0}) + ), true); + + Assertions.assertEquals(expectedWaypointCategory.waypoints().size(), waypointCategory.waypoints().size()); + for (int i = 0; i < waypointCategory.waypoints().size(); i++) { + Assertions.assertEquals(expectedWaypointCategory.waypoints().get(i), waypointCategory.waypoints().get(i)); + } + Assertions.assertEquals(expectedWaypointCategory.name(), waypointCategory.name()); + Assertions.assertEquals(expectedWaypointCategory.island(), waypointCategory.island()); + Assertions.assertEquals(expectedWaypointCategory.ordered(), waypointCategory.ordered()); + Assertions.assertEquals(expectedWaypointCategory, waypointCategory); + } } From 54c270663f2413021da7b49e7500bf6ea5469e91 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:01:59 -0400 Subject: [PATCH 04/18] Add soopy waypoints importing --- .../skyblock/waypoint/WaypointsShareScreen.java | 10 ++++++++++ src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index 3e6a1cf2c6..3c08c10b62 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -44,6 +44,16 @@ protected void init() { } }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkytils.tooltip"))).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy"), buttonImport -> { + try { + WaypointCategory waypointCategory = Waypoints.fromColeweightJson(client.keyboard.getClipboard(), island); + selectedWaypoints.addAll(waypointCategory.waypoints()); + waypoints.put(waypointCategory.island(), waypointCategory); + waypointsListWidget.updateEntries(); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointCategory.waypoints().size(), 1)); + } catch (Exception e) { + Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while parsing Snoopy waypoint data", e); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); + } }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy.tooltip"))).build()); adder.add(ButtonWidget.builder(ScreenTexts.BACK, buttonBack -> close()).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils"), buttonExport -> { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index ce3ede2684..dbb54979b5 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -957,7 +957,7 @@ "skyblocker.waypoints.importWaypointsSkytils": "Import Waypoints (Skytils)", "skyblocker.waypoints.importWaypointsSkytils.tooltip": "Import Waypoints from Clipboard (Skytils Format)", "skyblocker.waypoints.importWaypointsSnoopy": "Import Waypoints (Snoopy)", - "skyblocker.waypoints.importWaypointsSnoopy.tooltip": "Import Waypoints from Clipboard (Snoopy Format) (Coming Soon)", + "skyblocker.waypoints.importWaypointsSnoopy.tooltip": "Import Waypoints from Clipboard (Snoopy Format)", "skyblocker.waypoints.exportWaypointsSkytils": "Export Waypoints (Skytils)", "skyblocker.waypoints.exportWaypointsSkytils.tooltip": "Export Waypoints to Clipboard (Skytils Format)", "skyblocker.waypoints.importSuccess": "Waypoints Imported", From 5e0e1de54903bf037e353f195d58780d4e17f310 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:12:52 -0400 Subject: [PATCH 05/18] Refactor category to group --- .../waypoint/AbstractWaypointsScreen.java | 8 +- .../skyblock/waypoint/Waypoints.java | 66 +++++----- .../waypoint/WaypointsListWidget.java | 114 +++++++++--------- .../skyblock/waypoint/WaypointsScreen.java | 2 +- .../waypoint/WaypointsShareScreen.java | 28 ++--- ...ypointCategory.java => WaypointGroup.java} | 66 +++++----- .../assets/skyblocker/lang/en_us.json | 6 +- .../utils/waypoint/WaypointCategoryTest.java | 39 ------ .../utils/waypoint/WaypointGroupTest.java | 39 ++++++ .../utils/waypoint/WaypointsTest.java | 74 ++++++------ 10 files changed, 221 insertions(+), 221 deletions(-) rename src/main/java/de/hysky/skyblocker/utils/waypoint/{WaypointCategory.java => WaypointGroup.java} (62%) delete mode 100644 src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java create mode 100644 src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java index da6f52c871..feae3782ff 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java @@ -5,7 +5,7 @@ import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; -import de.hysky.skyblocker.utils.waypoint.WaypointCategory; +import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; @@ -13,7 +13,7 @@ public abstract class AbstractWaypointsScreen extends Screen { protected final T parent; - protected final Multimap waypoints; + protected final Multimap waypoints; protected String island; protected WaypointsListWidget waypointsListWidget; protected DropdownWidget islandWidget; @@ -22,11 +22,11 @@ public AbstractWaypointsScreen(Text title, T parent) { this(title, parent, MultimapBuilder.hashKeys().arrayListValues().build()); } - public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints) { + public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints) { this(title, parent, waypoints, Utils.getLocationRaw()); } - public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints, String island) { + public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints, String island) { super(title); this.parent = parent; this.waypoints = waypoints; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java index f02ed91b52..ecceefa125 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java @@ -12,7 +12,7 @@ import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; -import de.hysky.skyblocker.utils.waypoint.WaypointCategory; +import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; @@ -41,12 +41,12 @@ public class Waypoints { public static final Logger LOGGER = LoggerFactory.getLogger(Waypoints.class); - private static final Codec> CODEC = WaypointCategory.CODEC.listOf(); - private static final Codec> SKYTILS_CODEC = WaypointCategory.SKYTILS_CODEC.listOf(); + private static final Codec> CODEC = WaypointGroup.CODEC.listOf(); + private static final Codec> SKYTILS_CODEC = WaypointGroup.SKYTILS_CODEC.listOf(); protected static final SystemToast.Type WAYPOINTS_TOAST_TYPE = new SystemToast.Type(); private static final Path waypointsFile = FabricLoader.getInstance().getConfigDir().resolve(SkyblockerMod.NAMESPACE).resolve("waypoints.json"); - protected static final Multimap waypoints = MultimapBuilder.hashKeys().arrayListValues().build(); + protected static final Multimap waypoints = MultimapBuilder.hashKeys().arrayListValues().build(); @Init public static void init() { @@ -59,14 +59,14 @@ public static void init() { public static void loadWaypoints() { waypoints.clear(); try (BufferedReader reader = Files.newBufferedReader(waypointsFile)) { - List waypoints = CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(reader, JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow(); - waypoints.forEach(waypointCategory -> Waypoints.waypoints.put(waypointCategory.island(), waypointCategory)); + List waypoints = CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(reader, JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow(); + waypoints.forEach(waypointGroup -> Waypoints.waypoints.put(waypointGroup.island(), waypointGroup)); } catch (Exception e) { LOGGER.error("[Skyblocker Waypoints] Encountered exception while loading waypoints", e); } } - public static List fromSkytils(String waypointsString, String defaultIsland) { + public static List fromSkytils(String waypointsString, String defaultIsland) { try { if (waypointsString.startsWith("(V")) { int version = Integer.parseInt(waypointsString.substring(25, waypointsString.indexOf(')'))); @@ -87,35 +87,35 @@ public static List fromSkytils(String waypointsString, String return Collections.emptyList(); } - public static List fromSkytilsJson(String waypointCategoriesString, String defaultIsland) { - JsonArray waypointCategoriesJson; + public static List fromSkytilsJson(String waypointGroupsString, String defaultIsland) { + JsonArray waypointGroupsJson; try { - waypointCategoriesJson = SkyblockerMod.GSON.fromJson(waypointCategoriesString, JsonObject.class).getAsJsonArray("categories"); + waypointGroupsJson = SkyblockerMod.GSON.fromJson(waypointGroupsString, JsonObject.class).getAsJsonArray("categories"); } catch (JsonSyntaxException e) { - // Handle the case where there is only a single json list of waypoints and no category data. - JsonObject waypointCategoryJson = new JsonObject(); - waypointCategoryJson.addProperty("name", "New Category"); - waypointCategoryJson.addProperty("island", defaultIsland); - waypointCategoryJson.add("waypoints", SkyblockerMod.GSON.fromJson(waypointCategoriesString, JsonArray.class)); - waypointCategoriesJson = new JsonArray(); - waypointCategoriesJson.add(waypointCategoryJson); + // Handle the case where there is only a single json list of waypoints and no group data. + JsonObject waypointGroupJson = new JsonObject(); + waypointGroupJson.addProperty("name", "New Group"); + waypointGroupJson.addProperty("island", defaultIsland); + waypointGroupJson.add("waypoints", SkyblockerMod.GSON.fromJson(waypointGroupsString, JsonArray.class)); + waypointGroupsJson = new JsonArray(); + waypointGroupsJson.add(waypointGroupJson); } - List waypointCategories = SKYTILS_CODEC.parse(JsonOps.INSTANCE, waypointCategoriesJson).resultOrPartial(LOGGER::error).orElseThrow(); - return waypointCategories.stream().map(waypointCategory -> Location.from(waypointCategory.island()) == Location.UNKNOWN ? waypointCategory.withIsland(defaultIsland) : waypointCategory).toList(); + List waypointGroups = SKYTILS_CODEC.parse(JsonOps.INSTANCE, waypointGroupsJson).resultOrPartial(LOGGER::error).orElseThrow(); + return waypointGroups.stream().map(waypointGroup -> Location.from(waypointGroup.island()) == Location.UNKNOWN ? waypointGroup.withIsland(defaultIsland) : waypointGroup).toList(); } - public static String toSkytilsBase64(List waypointCategories) { - return Base64.getEncoder().encodeToString(toSkytilsJson(waypointCategories).getBytes()); + public static String toSkytilsBase64(List waypointGroups) { + return Base64.getEncoder().encodeToString(toSkytilsJson(waypointGroups).getBytes()); } - public static String toSkytilsJson(List waypointCategories) { - JsonObject waypointCategoriesJson = new JsonObject(); - waypointCategoriesJson.add("categories", SKYTILS_CODEC.encodeStart(JsonOps.INSTANCE, waypointCategories).resultOrPartial(LOGGER::error).orElseThrow()); - return SkyblockerMod.GSON_COMPACT.toJson(waypointCategoriesJson); + public static String toSkytilsJson(List waypointGroups) { + JsonObject waypointGroupsJson = new JsonObject(); + waypointGroupsJson.add("categories", SKYTILS_CODEC.encodeStart(JsonOps.INSTANCE, waypointGroups).resultOrPartial(LOGGER::error).orElseThrow()); + return SkyblockerMod.GSON_COMPACT.toJson(waypointGroupsJson); } - public static WaypointCategory fromColeweightJson(String waypointsJson, String defaultIsland) { - return WaypointCategory.COLEWEIGHT_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(waypointsJson)).resultOrPartial(LOGGER::error).orElseThrow().withIsland(defaultIsland); + public static WaypointGroup fromColeweightJson(String waypointsJson, String defaultIsland) { + return WaypointGroup.COLEWEIGHT_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(waypointsJson)).resultOrPartial(LOGGER::error).orElseThrow().withIsland(defaultIsland); } public static void saveWaypoints(MinecraftClient client) { @@ -128,16 +128,16 @@ public static void saveWaypoints(MinecraftClient client) { } } - public static Multimap waypointsDeepCopy() { - return waypoints.values().stream().map(WaypointCategory::deepCopy).collect(Multimaps.toMultimap(WaypointCategory::island, Function.identity(), () -> MultimapBuilder.hashKeys().arrayListValues().build())); + public static Multimap waypointsDeepCopy() { + return waypoints.values().stream().map(WaypointGroup::deepCopy).collect(Multimaps.toMultimap(WaypointGroup::island, Function.identity(), () -> MultimapBuilder.hashKeys().arrayListValues().build())); } public static void render(WorldRenderContext context) { if (SkyblockerConfigManager.get().uiAndVisuals.waypoints.enableWaypoints) { - Collection categories = waypoints.get(Utils.getLocationRaw()); - for (WaypointCategory category : categories) { - if (category != null) { - category.render(context); + Collection groups = waypoints.get(Utils.getLocationRaw()); + for (WaypointGroup group : groups) { + if (group != null) { + group.render(context); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java index 4effc5a548..06e4d00b69 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java @@ -2,7 +2,7 @@ import de.hysky.skyblocker.mixins.accessors.CheckboxWidgetAccessor; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; -import de.hysky.skyblocker.utils.waypoint.WaypointCategory; +import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; @@ -22,7 +22,7 @@ public class WaypointsListWidget extends ElementListWidget { private final AbstractWaypointsScreen screen; private String island; - private List waypoints; + private List waypoints; public WaypointsListWidget(MinecraftClient client, AbstractWaypointsScreen screen, int width, int height, int y, int itemHeight) { super(client, width, height, y, itemHeight); @@ -40,53 +40,53 @@ protected int getScrollbarX() { return super.getScrollbarX(); } - Optional getCategory() { - if (getSelectedOrNull() instanceof WaypointCategoryEntry category) { - return Optional.of(category); + Optional getGroup() { + if (getSelectedOrNull() instanceof WaypointGroupEntry groupEntry) { + return Optional.of(groupEntry); } else if (getSelectedOrNull() instanceof WaypointEntry waypointEntry) { - return Optional.of(waypointEntry.category); + return Optional.of(waypointEntry.groupEntry); } return Optional.empty(); } void setIsland(String island) { this.island = island; - waypoints = (List) screen.waypoints.get(island); + waypoints = (List) screen.waypoints.get(island); updateEntries(); } - void addWaypointCategoryAfterSelected() { - WaypointCategoryEntry categoryEntry = new WaypointCategoryEntry(); - Optional selectedCategoryEntryOptional = getCategory(); + void addWaypointGroupAfterSelected() { + WaypointGroupEntry groupEntry = new WaypointGroupEntry(); + Optional selectedGroupEntryOptional = getGroup(); int index = waypoints.size(); int entryIndex = children().size(); - if (selectedCategoryEntryOptional.isPresent()) { - WaypointCategoryEntry selectedCategoryEntry = selectedCategoryEntryOptional.get(); - index = waypoints.indexOf(selectedCategoryEntry.category) + 1; - entryIndex = children().indexOf(selectedCategoryEntry) + 1; - while (entryIndex < children().size() && !(children().get(entryIndex) instanceof WaypointCategoryEntry)) { + if (selectedGroupEntryOptional.isPresent()) { + WaypointGroupEntry selectedGroupEntry = selectedGroupEntryOptional.get(); + index = waypoints.indexOf(selectedGroupEntry.group) + 1; + entryIndex = children().indexOf(selectedGroupEntry) + 1; + while (entryIndex < children().size() && !(children().get(entryIndex) instanceof WaypointGroupEntry)) { entryIndex++; } } - waypoints.add(index, categoryEntry.category); - children().add(entryIndex, categoryEntry); + waypoints.add(index, groupEntry.group); + children().add(entryIndex, groupEntry); } void updateEntries() { clearEntries(); - for (WaypointCategory category : waypoints) { - WaypointCategoryEntry categoryEntry = new WaypointCategoryEntry(category); - addEntry(categoryEntry); - for (NamedWaypoint waypoint : category.waypoints()) { - addEntry(new WaypointEntry(categoryEntry, waypoint)); + for (WaypointGroup group : waypoints) { + WaypointGroupEntry groupEntry = new WaypointGroupEntry(group); + addEntry(groupEntry); + for (NamedWaypoint waypoint : group.waypoints()) { + addEntry(new WaypointEntry(groupEntry, waypoint)); } } } void updateButtons() { for (Entry entry : children()) { - if (entry instanceof WaypointCategoryEntry categoryEntry && categoryEntry.enabled.isChecked() != categoryEntry.shouldBeChecked()) { - ((CheckboxWidgetAccessor) categoryEntry.enabled).setChecked(!categoryEntry.enabled.isChecked()); + if (entry instanceof WaypointGroupEntry groupEntry && groupEntry.enabled.isChecked() != groupEntry.shouldBeChecked()) { + ((CheckboxWidgetAccessor) groupEntry.enabled).setChecked(!groupEntry.enabled.isChecked()); } else if (entry instanceof WaypointEntry waypointEntry && waypointEntry.enabled.isChecked() != screen.isEnabled(waypointEntry.waypoint)) { waypointEntry.enabled.onPress(); } @@ -100,8 +100,8 @@ private BlockPos getDefaultPos() { protected abstract static class AbstractWaypointEntry extends ElementListWidget.Entry { } - protected class WaypointCategoryEntry extends AbstractWaypointEntry { - private WaypointCategory category; + protected class WaypointGroupEntry extends AbstractWaypointEntry { + private WaypointGroup group; private final List children; private final CheckboxWidget enabled; private final TextFieldWidget nameField; @@ -109,38 +109,38 @@ protected class WaypointCategoryEntry extends AbstractWaypointEntry { private final ButtonWidget buttonNewWaypoint; private final ButtonWidget buttonDelete; - public WaypointCategoryEntry() { - this(new WaypointCategory("New Category", island, new ArrayList<>())); + public WaypointGroupEntry() { + this(new WaypointGroup("New Group", island, new ArrayList<>())); } - public WaypointCategoryEntry(WaypointCategory category) { - this.category = category; - enabled = CheckboxWidget.builder(Text.literal(""), client.textRenderer).checked(shouldBeChecked()).callback((checkbox, checked) -> category.waypoints().forEach(waypoint -> screen.enabledChanged(waypoint, checked))).build(); + public WaypointGroupEntry(WaypointGroup group) { + this.group = group; + enabled = CheckboxWidget.builder(Text.literal(""), client.textRenderer).checked(shouldBeChecked()).callback((checkbox, checked) -> group.waypoints().forEach(waypoint -> screen.enabledChanged(waypoint, checked))).build(); nameField = new TextFieldWidget(client.textRenderer, 70, 20, Text.literal("Name")); - nameField.setText(category.name()); + nameField.setText(group.name()); nameField.setChangedListener(this::updateName); - ordered = CheckboxWidget.builder(Text.literal("Ordered"), client.textRenderer).checked(category.ordered()).callback((checkbox, checked) -> updateOrdered(checked)).build(); + ordered = CheckboxWidget.builder(Text.literal("Ordered"), client.textRenderer).checked(group.ordered()).callback((checkbox, checked) -> updateOrdered(checked)).build(); buttonNewWaypoint = ButtonWidget.builder(Text.translatable("skyblocker.waypoints.new"), buttonNewWaypoint -> { WaypointEntry waypointEntry = new WaypointEntry(this); int entryIndex; - if (getSelectedOrNull() instanceof WaypointEntry selectedWaypointEntry && selectedWaypointEntry.category == this) { + if (getSelectedOrNull() instanceof WaypointEntry selectedWaypointEntry && selectedWaypointEntry.groupEntry == this) { entryIndex = WaypointsListWidget.this.children().indexOf(selectedWaypointEntry) + 1; } else { entryIndex = WaypointsListWidget.this.children().indexOf(this) + 1; - while (entryIndex < WaypointsListWidget.this.children().size() && !(WaypointsListWidget.this.children().get(entryIndex) instanceof WaypointCategoryEntry)) { + while (entryIndex < WaypointsListWidget.this.children().size() && !(WaypointsListWidget.this.children().get(entryIndex) instanceof WaypointGroupEntry)) { entryIndex++; } } - category.waypoints().add(waypointEntry.waypoint); + group.waypoints().add(waypointEntry.waypoint); WaypointsListWidget.this.children().add(entryIndex, waypointEntry); }).width(72).build(); buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.deleteButton"), buttonDelete -> { int entryIndex = WaypointsListWidget.this.children().indexOf(this) + 1; - while (entryIndex < WaypointsListWidget.this.children().size() && !(WaypointsListWidget.this.children().get(entryIndex) instanceof WaypointCategoryEntry)) { + while (entryIndex < WaypointsListWidget.this.children().size() && !(WaypointsListWidget.this.children().get(entryIndex) instanceof WaypointGroupEntry)) { WaypointsListWidget.this.children().remove(entryIndex); } WaypointsListWidget.this.children().remove(this); - waypoints.remove(category); + waypoints.remove(group); }).width(38).build(); children = List.of(enabled, nameField, ordered, buttonNewWaypoint, buttonDelete); } @@ -156,22 +156,22 @@ public List children() { } private boolean shouldBeChecked() { - return !category.waypoints().isEmpty() && category.waypoints().stream().allMatch(screen::isEnabled); + return !group.waypoints().isEmpty() && group.waypoints().stream().allMatch(screen::isEnabled); } private void updateName(String name) { - int index = waypoints.indexOf(category); - category = category.withName(name); + int index = waypoints.indexOf(group); + group = group.withName(name); if (index >= 0) { - waypoints.set(index, category); + waypoints.set(index, group); } } private void updateOrdered(boolean ordered) { - int index = waypoints.indexOf(category); - category = category.withOrdered(ordered); + int index = waypoints.indexOf(group); + group = group.withOrdered(ordered); if (index >= 0) { - waypoints.set(index, category); + waypoints.set(index, group); } } @@ -189,7 +189,7 @@ public void render(DrawContext context, int index, int y, int x, int entryWidth, } protected class WaypointEntry extends AbstractWaypointEntry { - private final WaypointCategoryEntry category; + private final WaypointGroupEntry groupEntry; private NamedWaypoint waypoint; private final List children; private final CheckboxWidget enabled; @@ -200,12 +200,12 @@ protected class WaypointEntry extends AbstractWaypointEntry { private final TextFieldWidget colorField; private final ButtonWidget buttonDelete; - public WaypointEntry(WaypointCategoryEntry category) { - this(category, category.category.createWaypoint(getDefaultPos())); + public WaypointEntry(WaypointGroupEntry groupEntry) { + this(groupEntry, groupEntry.group.createWaypoint(getDefaultPos())); } - public WaypointEntry(WaypointCategoryEntry category, NamedWaypoint waypoint) { - this.category = category; + public WaypointEntry(WaypointGroupEntry groupEntry, NamedWaypoint waypoint) { + this.groupEntry = groupEntry; this.waypoint = waypoint; enabled = CheckboxWidget.builder(Text.literal(""), client.textRenderer).checked(screen.isEnabled(waypoint)).callback((checkbox, checked) -> screen.enabledChanged(waypoint, checked)).build(); nameField = new TextFieldWidget(client.textRenderer, 65, 20, Text.literal("Name")); @@ -227,7 +227,7 @@ public WaypointEntry(WaypointCategoryEntry category, NamedWaypoint waypoint) { colorField.setText(String.format("%02X%02X%02X%02X", (int) (waypoint.alpha * 255), (int) (waypoint.colorComponents[0] * 255), (int) (waypoint.colorComponents[1] * 255), (int) (waypoint.colorComponents[2] * 255))); colorField.setChangedListener(this::updateColor); buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.deleteButton"), button -> { - category.category.waypoints().remove(waypoint); + groupEntry.group.waypoints().remove(waypoint); WaypointsListWidget.this.children().remove(this); }).width(38).build(); children = List.of(enabled, nameField, xField, yField, zField, colorField, buttonDelete); @@ -245,10 +245,10 @@ public List children() { private void updateName(String name) { if (waypoint.name.getString().equals(name)) return; - int index = category.category.waypoints().indexOf(waypoint); + int index = groupEntry.group.waypoints().indexOf(waypoint); waypoint = waypoint.withName(name); if (index >= 0) { - category.category.waypoints().set(index, waypoint); + groupEntry.group.waypoints().set(index, waypoint); } } @@ -275,12 +275,12 @@ private void updateZ(String zString) { private void updateInt(String newValueString, int currentValue, Int2ObjectFunction wither) { try { - int index = category.category.waypoints().indexOf(waypoint); + int index = groupEntry.group.waypoints().indexOf(waypoint); int newValue = parseEmptiableInt(newValueString); if (newValue == currentValue) return; waypoint = wither.apply(newValue); if (index >= 0) { - category.category.waypoints().set(index, waypoint); + groupEntry.group.waypoints().set(index, waypoint); } } catch (NumberFormatException e) { Waypoints.LOGGER.warn("[Skyblocker Waypoints] Failed to parse integer: {}", newValueString, e); @@ -289,14 +289,14 @@ private void updateInt(String newValueString, int currentValue, Int2ObjectFuncti private void updateColor(String colorString) { try { - int index = category.category.waypoints().indexOf(waypoint); + int index = groupEntry.group.waypoints().indexOf(waypoint); int colorInt = parseEmptiableInt(colorString, 16); float[] colorComponents = {((colorInt & 0x00FF0000) >> 16) / 255f, ((colorInt & 0x0000FF00) >> 8) / 255f, (colorInt & 0x000000FF) / 255f}; float alpha = ((colorInt & 0xFF000000) >>> 24) / 255f; if (Arrays.equals(waypoint.colorComponents, colorComponents) && waypoint.alpha == alpha) return; waypoint = waypoint.withColor(colorComponents, alpha); if (index >= 0) { - category.category.waypoints().set(index, waypoint); + groupEntry.group.waypoints().set(index, waypoint); } } catch (NumberFormatException e) { Waypoints.LOGGER.warn("[Skyblocker Waypoints] Failed to parse color: {}", colorString, e); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java index f5d39834dd..b1c2acbde7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsScreen.java @@ -25,7 +25,7 @@ protected void init() { gridWidget.getMainPositioner().marginX(5).marginY(2); GridWidget.Adder adder = gridWidget.createAdder(2); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.share"), buttonShare -> client.setScreen(new WaypointsShareScreen(this, waypoints))).build()); - buttonNew = adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.newCategory"), buttonNew -> waypointsListWidget.addWaypointCategoryAfterSelected()).build()); + buttonNew = adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.newGroup"), buttonNew -> waypointsListWidget.addWaypointGroupAfterSelected()).build()); adder.add(ButtonWidget.builder(ScreenTexts.CANCEL, button -> close()).build()); buttonDone = adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> { saveWaypoints(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index 3c08c10b62..51967a761f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -2,7 +2,7 @@ import com.google.common.collect.Multimap; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; -import de.hysky.skyblocker.utils.waypoint.WaypointCategory; +import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; @@ -19,7 +19,7 @@ public class WaypointsShareScreen extends AbstractWaypointsScreen { private final Set selectedWaypoints = new HashSet<>(); - protected WaypointsShareScreen(WaypointsScreen parent, Multimap waypoints) { + protected WaypointsShareScreen(WaypointsScreen parent, Multimap waypoints) { super(Text.translatable("skyblocker.waypoints.shareWaypoints"), parent, waypoints, parent.island); } @@ -31,13 +31,13 @@ protected void init() { GridWidget.Adder adder = gridWidget.createAdder(2); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSkytils"), buttonImport -> { try { - List waypointCategories = Waypoints.fromSkytils(client.keyboard.getClipboard(), island); - for (WaypointCategory waypointCategory : waypointCategories) { - selectedWaypoints.addAll(waypointCategory.waypoints()); - waypoints.put(waypointCategory.island(), waypointCategory); + List waypointGroups = Waypoints.fromSkytils(client.keyboard.getClipboard(), island); + for (WaypointGroup waypointGroup : waypointGroups) { + selectedWaypoints.addAll(waypointGroup.waypoints()); + waypoints.put(waypointGroup.island(), waypointGroup); } waypointsListWidget.updateEntries(); - SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointCategories.stream().map(WaypointCategory::waypoints).mapToInt(List::size).sum(), waypointCategories.size())); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); } catch (Exception e) { Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while parsing Skytils waypoint data", e); SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); @@ -45,11 +45,11 @@ protected void init() { }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkytils.tooltip"))).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy"), buttonImport -> { try { - WaypointCategory waypointCategory = Waypoints.fromColeweightJson(client.keyboard.getClipboard(), island); - selectedWaypoints.addAll(waypointCategory.waypoints()); - waypoints.put(waypointCategory.island(), waypointCategory); + WaypointGroup waypointGroup = Waypoints.fromColeweightJson(client.keyboard.getClipboard(), island); + selectedWaypoints.addAll(waypointGroup.waypoints()); + waypoints.put(waypointGroup.island(), waypointGroup); waypointsListWidget.updateEntries(); - SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointCategory.waypoints().size(), 1)); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointGroup.waypoints().size(), 1)); } catch (Exception e) { Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while parsing Snoopy waypoint data", e); SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); @@ -58,9 +58,9 @@ protected void init() { adder.add(ButtonWidget.builder(ScreenTexts.BACK, buttonBack -> close()).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils"), buttonExport -> { try { - List waypointCategories = waypoints.values().stream().filter(waypointCategory -> waypointCategory.island().equals(island)).map(waypointCategory -> waypointCategory.filterWaypoints(selectedWaypoints::contains)).filter(waypointCategory -> !waypointCategory.waypoints().isEmpty()).toList(); - client.keyboard.setClipboard(Waypoints.toSkytilsBase64(waypointCategories)); - SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointCategories.stream().map(WaypointCategory::waypoints).mapToInt(List::size).sum(), waypointCategories.size())); + List waypointGroups = waypoints.values().stream().filter(waypointGroup -> waypointGroup.island().equals(island)).map(waypointGroup -> waypointGroup.filterWaypoints(selectedWaypoints::contains)).filter(waypointGroup -> !waypointGroup.waypoints().isEmpty()).toList(); + client.keyboard.setClipboard(Waypoints.toSkytilsBase64(waypointGroups)); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); } catch (Exception e) { Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skytils waypoint data", e); SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportError"), Text.translatable("skyblocker.waypoints.exportErrorText")); diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java similarity index 62% rename from src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java rename to src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java index 90849b9aca..039b7ff473 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointCategory.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java @@ -12,20 +12,20 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -public class WaypointCategory { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.STRING.fieldOf("name").forGetter(WaypointCategory::name), - Codec.STRING.fieldOf("island").forGetter(WaypointCategory::island), - NamedWaypoint.CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints), - Codec.BOOL.lenientOptionalFieldOf("ordered", false).forGetter(WaypointCategory::ordered), - Codec.INT.lenientOptionalFieldOf("currentIndex", 0).forGetter(category -> category.currentIndex) - ).apply(instance, WaypointCategory::new)); - public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.STRING.fieldOf("name").forGetter(WaypointCategory::name), - Codec.STRING.fieldOf("island").forGetter(WaypointCategory::island), - NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointCategory::waypoints) - ).apply(instance, WaypointCategory::new)); - public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointCategory("Coleweight", "", coleWeightWaypoints, true), WaypointCategory::waypoints); +public class WaypointGroup { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.STRING.fieldOf("name").forGetter(WaypointGroup::name), + Codec.STRING.fieldOf("island").forGetter(WaypointGroup::island), + NamedWaypoint.CODEC.listOf().fieldOf("waypoints").forGetter(WaypointGroup::waypoints), + Codec.BOOL.lenientOptionalFieldOf("ordered", false).forGetter(WaypointGroup::ordered), + Codec.INT.lenientOptionalFieldOf("currentIndex", 0).forGetter(group -> group.currentIndex) + ).apply(instance, WaypointGroup::new)); + public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.STRING.fieldOf("name").forGetter(WaypointGroup::name), + Codec.STRING.fieldOf("island").forGetter(WaypointGroup::island), + NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointGroup::waypoints) + ).apply(instance, WaypointGroup::new)); + public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointGroup("Coleweight", "", coleWeightWaypoints, true), WaypointGroup::waypoints); private final String name; private final String island; @@ -33,15 +33,15 @@ public class WaypointCategory { private final boolean ordered; protected int currentIndex; - public WaypointCategory(String name, String island, List waypoints) { + public WaypointGroup(String name, String island, List waypoints) { this(name, island, waypoints, false); } - public WaypointCategory(String name, String island, List waypoints, boolean ordered) { + public WaypointGroup(String name, String island, List waypoints, boolean ordered) { this(name, island, waypoints, ordered, 0); } - public WaypointCategory(String name, String island, List waypoints, boolean ordered, int currentIndex) { + public WaypointGroup(String name, String island, List waypoints, boolean ordered, int currentIndex) { this.name = name; this.island = island; // Set ordered first since convertWaypoint depends on it @@ -66,27 +66,27 @@ public boolean ordered() { return ordered; } - public WaypointCategory withName(String name) { - return new WaypointCategory(name, island, waypoints, ordered, currentIndex); + public WaypointGroup withName(String name) { + return new WaypointGroup(name, island, waypoints, ordered, currentIndex); } - public WaypointCategory withIsland(String island) { - return new WaypointCategory(name, island, waypoints, ordered, currentIndex); + public WaypointGroup withIsland(String island) { + return new WaypointGroup(name, island, waypoints, ordered, currentIndex); } - public WaypointCategory withOrdered(boolean ordered) { - return new WaypointCategory(name, island, waypoints, ordered, currentIndex); + public WaypointGroup withOrdered(boolean ordered) { + return new WaypointGroup(name, island, waypoints, ordered, currentIndex); } - public WaypointCategory filterWaypoints(Predicate predicate) { - return new WaypointCategory(name, island, waypoints.stream().filter(predicate).toList(), ordered, currentIndex); + public WaypointGroup filterWaypoints(Predicate predicate) { + return new WaypointGroup(name, island, waypoints.stream().filter(predicate).toList(), ordered, currentIndex); } /** - * Returns a deep copy of this {@link WaypointCategory} with a mutable waypoints list for editing. + * Returns a deep copy of this {@link WaypointGroup} with a mutable waypoints list for editing. */ - public WaypointCategory deepCopy() { - return new WaypointCategory(name, island, waypoints.stream().map(NamedWaypoint::copy).collect(Collectors.toList()), ordered, currentIndex); + public WaypointGroup deepCopy() { + return new WaypointGroup(name, island, waypoints.stream().map(NamedWaypoint::copy).collect(Collectors.toList()), ordered, currentIndex); } public NamedWaypoint createWaypoint(BlockPos pos) { @@ -95,7 +95,7 @@ public NamedWaypoint createWaypoint(BlockPos pos) { } /** - * Converts the given waypoint to the correct type based on whether this category is ordered or not. + * Converts the given waypoint to the correct type based on whether this group is ordered or not. */ public NamedWaypoint convertWaypoint(NamedWaypoint waypoint) { if (ordered) { @@ -114,15 +114,15 @@ public void render(WorldRenderContext context) { } } - int categoryPreviousIndex = (currentIndex - 1 + waypoints.size()) % waypoints.size(); - int categoryNextIndex = (currentIndex + 1) % waypoints.size(); + int previousIndex = (currentIndex - 1 + waypoints.size()) % waypoints.size(); + int nextIndex = (currentIndex + 1) % waypoints.size(); for (int i = 0; i < waypoints.size(); i++) { NamedWaypoint waypoint = waypoints.get(i); if (waypoint instanceof OrderedNamedWaypoint orderedNamedWaypoint) { orderedNamedWaypoint.index = i; - if (i == categoryPreviousIndex) { + if (i == previousIndex) { orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.PREVIOUS; - } else if (i == categoryNextIndex) { + } else if (i == nextIndex) { orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.NEXT; } else if (i == currentIndex) { orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.CURRENT; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index dbb54979b5..89edb22e29 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -950,7 +950,7 @@ "skyblocker.shortcuts.commandSuggestionTooltip": "Due to limitations of Minecraft, command suggestions will only work after joining a new world.", "skyblocker.waypoints.config": "Waypoints Config", - "skyblocker.waypoints.newCategory": "New Waypoint Category", + "skyblocker.waypoints.newGroup": "New Waypoint Group", "skyblocker.waypoints.new": "New Waypoint", "skyblocker.waypoints.share": "Share", "skyblocker.waypoints.shareWaypoints": "Share Waypoints", @@ -961,11 +961,11 @@ "skyblocker.waypoints.exportWaypointsSkytils": "Export Waypoints (Skytils)", "skyblocker.waypoints.exportWaypointsSkytils.tooltip": "Export Waypoints to Clipboard (Skytils Format)", "skyblocker.waypoints.importSuccess": "Waypoints Imported", - "skyblocker.waypoints.importSuccessText": "Successfully imported %d waypoints from %d categories.", + "skyblocker.waypoints.importSuccessText": "Successfully imported %d waypoint(s) from %d group(s).", "skyblocker.waypoints.importError": "Error Importing Waypoints", "skyblocker.waypoints.importErrorText": "Failed to import waypoints. See logs for details.", "skyblocker.waypoints.exportSuccess": "Waypoints Exported", - "skyblocker.waypoints.exportSuccessText": "Successfully exported %d waypoints from %d categories.", + "skyblocker.waypoints.exportSuccessText": "Successfully exported %d waypoint(s) from %d group(s).", "skyblocker.waypoints.exportError": "Error Exporting Waypoints", "skyblocker.waypoints.exportErrorText": "Failed to export waypoints. See logs for details.", "skyblocker.waypoints.deleteQuestion": "Are you sure you want to remove this waypoint?", diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java deleted file mode 100644 index 79f0abd41e..0000000000 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointCategoryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.hysky.skyblocker.utils.waypoint; - -import com.google.gson.JsonElement; -import com.mojang.serialization.JsonOps; -import de.hysky.skyblocker.SkyblockerMod; -import net.minecraft.Bootstrap; -import net.minecraft.SharedConstants; -import net.minecraft.util.math.BlockPos; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.util.List; - -public class WaypointCategoryTest { - @BeforeAll - static void beforeAll() { - SharedConstants.createGameVersion(); - Bootstrap.initialize(); - } - - @Test - void testCodecEncode() { - WaypointCategory category = new WaypointCategory("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); - JsonElement categoryJson = WaypointCategory.CODEC.encodeStart(JsonOps.INSTANCE, category).result().orElseThrow(); - JsonElement expectedJson = SkyblockerMod.GSON.fromJson("{\"name\":\"category\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}", JsonElement.class); - - Assertions.assertEquals(expectedJson, categoryJson); - } - - @Test - void testCodecDecode() { - String categoryJson = "{\"name\":\"category\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}"; - WaypointCategory category = WaypointCategory.CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(categoryJson, JsonElement.class)).result().orElseThrow(); - WaypointCategory expectedCategory = new WaypointCategory("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); - - Assertions.assertEquals(expectedCategory, category); - } -} diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java new file mode 100644 index 0000000000..fca053d675 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java @@ -0,0 +1,39 @@ +package de.hysky.skyblocker.utils.waypoint; + +import com.google.gson.JsonElement; +import com.mojang.serialization.JsonOps; +import de.hysky.skyblocker.SkyblockerMod; +import net.minecraft.Bootstrap; +import net.minecraft.SharedConstants; +import net.minecraft.util.math.BlockPos; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.util.List; + +public class WaypointGroupTest { + @BeforeAll + static void beforeAll() { + SharedConstants.createGameVersion(); + Bootstrap.initialize(); + } + + @Test + void testCodecEncode() { + WaypointGroup group = new WaypointGroup("group", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); + JsonElement groupJson = WaypointGroup.CODEC.encodeStart(JsonOps.INSTANCE, group).result().orElseThrow(); + JsonElement expectedJson = SkyblockerMod.GSON.fromJson("{\"name\":\"group\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}", JsonElement.class); + + Assertions.assertEquals(expectedJson, groupJson); + } + + @Test + void testCodecDecode() { + String groupJson = "{\"name\":\"group\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}"; + WaypointGroup group = WaypointGroup.CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(groupJson, JsonElement.class)).result().orElseThrow(); + WaypointGroup expectedGroup = new WaypointGroup("group", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); + + Assertions.assertEquals(expectedGroup, group); + } +} diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java index 7928bac64c..83ad6eba6c 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java @@ -19,28 +19,28 @@ public static void setup() { @Test void testFromSkytilsBase64() { - String waypointCategoriesSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsIngiOjAsInkiOjAsInoiOjAsImVuYWJsZWQiOmZhbHNlLCJjb2xvciI6LTg3MjM4MjIwOSwiYWRkZWRBdCI6MX0seyJuYW1lIjoxLCJ4IjotMSwieSI6MCwieiI6MSwiZW5hYmxlZCI6dHJ1ZSwiY29sb3IiOjAsImFkZGVkQXQiOjF9XSwiaXNsYW5kIjoiaHViIn1dfQ=="; - List waypointCategories = Waypoints.fromSkytils(waypointCategoriesSkytilsBase64, ""); - List expectedWaypointCategories = List.of(new WaypointCategory("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5019608f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); + String waypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsIngiOjAsInkiOjAsInoiOjAsImVuYWJsZWQiOmZhbHNlLCJjb2xvciI6LTg3MjM4MjIwOSwiYWRkZWRBdCI6MX0seyJuYW1lIjoxLCJ4IjotMSwieSI6MCwieiI6MSwiZW5hYmxlZCI6dHJ1ZSwiY29sb3IiOjAsImFkZGVkQXQiOjF9XSwiaXNsYW5kIjoiaHViIn1dfQ=="; + List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, ""); + List expectedWaypointGroups = List.of(new WaypointGroup("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5019608f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); - Assertions.assertEquals(expectedWaypointCategories, waypointCategories); + Assertions.assertEquals(expectedWaypointGroups, waypointGroups); } @Test void testToSkytilsBase64() { - List waypointCategories = List.of(new WaypointCategory("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); - String waypointCategoriesSkytilsBase64 = Waypoints.toSkytilsBase64(waypointCategories); - String expectedWaypointCategoriesSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJpc2xhbmQiOiJodWIiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsImNvbG9yIjotODcyMzgyNDY1LCJlbmFibGVkIjpmYWxzZSwieCI6MCwieSI6MCwieiI6MH0seyJuYW1lIjoiMSIsImNvbG9yIjoyMTMwNzA2NDMyLCJlbmFibGVkIjp0cnVlLCJ4IjotMSwieSI6MCwieiI6MX1dfV19"; + List waypointGroups = List.of(new WaypointGroup("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); + String waypointGroupsSkytilsBase64 = Waypoints.toSkytilsBase64(waypointGroups); + String expectedWaypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJpc2xhbmQiOiJodWIiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsImNvbG9yIjotODcyMzgyNDY1LCJlbmFibGVkIjpmYWxzZSwieCI6MCwieSI6MCwieiI6MH0seyJuYW1lIjoiMSIsImNvbG9yIjoyMTMwNzA2NDMyLCJlbmFibGVkIjp0cnVlLCJ4IjotMSwieSI6MCwieiI6MX1dfV19"; - Assertions.assertEquals(expectedWaypointCategoriesSkytilsBase64, waypointCategoriesSkytilsBase64); + Assertions.assertEquals(expectedWaypointGroupsSkytilsBase64, waypointGroupsSkytilsBase64); } //https://sharetext.me/gq22cbhdmo @Test void testFromSkytilsBase64GlacialCaveWaypoints() { - String waypointCategoriesSkytilsBase64 = "eyJjYXRlZ29yaWVzIjogW3sibmFtZSI6ICJGcm96ZW4gVHJlYXN1cmUgTG9jYXRpb25zIiwid2F5cG9pbnRzIjogW3sibmFtZSI6ICIyNCIsIngiOiA2NCwieSI6IDc4LCJ6IjogMjgsImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODU0MDY3MTksImFkZGVkQXQiOiAxNjY5OTk5NzUwNjc3fSx7Im5hbWUiOiAiOSIsIngiOiA0NSwieSI6IDc5LCJ6IjogNDksImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODUyNzM1OTksImFkZGVkQXQiOiAxNjY5OTk5NTEwMTA3fSx7Im5hbWUiOiAiMjAiLCJ4IjogNjAsInkiOiA3NiwieiI6IDUxLCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiA5NTMzNTE5MzUsImFkZGVkQXQiOiAxNjY5OTk5NzQ5MzI3fSx7Im5hbWUiOiAiMjMiLCJ4IjogNjMsInkiOiA3NiwieiI6IDk1LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDIwNDYxMDUyLCJhZGRlZEF0IjogMTY2OTk5OTc1MDQ3N30seyJuYW1lIjogIjIyIiwieCI6IDYzLCJ5IjogNzYsInoiOiA1MiwiZW5hYmxlZCI6IH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MTc0fSx7Im5hbWUiOiAiMzciLCJ4IjogOTEsInkiOiA3NiwieiI6IDM4LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDUxMTMxMzkxLCJhZGRlZEF0IjogMTY3MDAwMDIyNjQyM30seyJuYW1lIjogIjQ1IiwieCI6IDk4LCJ5IjogNzgsInoiOiA3NSwiZW5hYmxlZCI6IHRydWUsImNvbG9yIjogMTIwMjg0NzczNywiYWRkZWRBdCI6IDE2NzAwMDAyMjgwNzN9XSwiaXNsYW5kIjogIndpbnRlciJ9XX0="; - List waypointCategories = Waypoints.fromSkytils(waypointCategoriesSkytilsBase64, ""); - List expectedWaypointCategories = List.of(new WaypointCategory("Frozen Treasure Locations", "winter", List.of( + String waypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjogW3sibmFtZSI6ICJGcm96ZW4gVHJlYXN1cmUgTG9jYXRpb25zIiwid2F5cG9pbnRzIjogW3sibmFtZSI6ICIyNCIsIngiOiA2NCwieSI6IDc4LCJ6IjogMjgsImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODU0MDY3MTksImFkZGVkQXQiOiAxNjY5OTk5NzUwNjc3fSx7Im5hbWUiOiAiOSIsIngiOiA0NSwieSI6IDc5LCJ6IjogNDksImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODUyNzM1OTksImFkZGVkQXQiOiAxNjY5OTk5NTEwMTA3fSx7Im5hbWUiOiAiMjAiLCJ4IjogNjAsInkiOiA3NiwieiI6IDUxLCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiA5NTMzNTE5MzUsImFkZGVkQXQiOiAxNjY5OTk5NzQ5MzI3fSx7Im5hbWUiOiAiMjMiLCJ4IjogNjMsInkiOiA3NiwieiI6IDk1LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDIwNDYxMDUyLCJhZGRlZEF0IjogMTY2OTk5OTc1MDQ3N30seyJuYW1lIjogIjIyIiwieCI6IDYzLCJ5IjogNz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ImFkZGVkQXQiOiAxNjcwMDAwMDIyMTc0fSx7Im5hbWUiOiAiMzciLCJ4IjogOTEsInkiOiA3NiwieiI6IDM4LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDUxMTMxMzkxLCJhZGRlZEF0IjogMTY3MDAwMDIyNjQyM30seyJuYW1lIjogIjQ1IiwieCI6IDk4LCJ5IjogNzgsInoiOiA3NSwiZW5hYmxlZCI6IHRydWUsImNvbG9yIjogMTIwMjg0NzczNywiYWRkZWRBdCI6IDE2NzAwMDAyMjgwNzN9XSwiaXNsYW5kIjogIndpbnRlciJ9XX0="; + List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, ""); + List expectedWaypointGroups = List.of(new WaypointGroup("Frozen Treasure Locations", "winter", List.of( new NamedWaypoint(new BlockPos(64, 78, 28), "24", new float[]{177 / 255f, 253 / 255f, 255 / 255f}, 64 / 255f, true), new NamedWaypoint(new BlockPos(45, 79, 49), "9", new float[]{175 / 255f, 245 / 255f, 255 / 255f}, 64 / 255f, true), new NamedWaypoint(new BlockPos(60, 76, 51), "20", new float[]{210 / 255f, 254 / 255f, 255 / 255f}, 56 / 255f, true), @@ -90,15 +90,15 @@ void testFromSkytilsBase64GlacialCaveWaypoints() { new NamedWaypoint(new BlockPos(98, 78, 75), "45", new float[]{177 / 255f, 255 / 255f, 249 / 255f}, 71 / 255f, true) ))); - Assertions.assertEquals(expectedWaypointCategories, waypointCategories); + Assertions.assertEquals(expectedWaypointGroups, waypointGroups); } //https://pastebin.com/c4PjUZjJ @Test void testFromSkytilsBase64CrystalHollowsWaypoints() { String waypointsSkytilsBase64 = "W3sibmFtZSI6IlNob3V0b3V0IFRlYmV5IGFuZCB0cmV2YW55YSIsIngiOjUxMCwieSI6NTMsInoiOjM5MywiaXNsYW5kIjoiY3J5c3RhbF9ob2xsb3dzIiwiZW5hYmxlZCI6dHJ1ZSwiY29sb3IiOi02NTUzNn0seyJuYW1lIjoiMDciLCJ4Ijo0NzksInk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crystal_hollows"); - List expectedWaypointCategories = List.of(new WaypointCategory("New Category", "crystal_hollows", List.of( + List waypointGroups = Waypoints.fromSkytils(waypointsSkytilsBase64, "crystal_hollows"); + List expectedWaypointGroups = List.of(new WaypointGroup("New Group", "crystal_hollows", List.of( new NamedWaypoint(new BlockPos(510, 53, 393), "Shoutout Tebey and trevanya", new float[]{1, 0, 0}, 1, true), new NamedWaypoint(new BlockPos(479, 39, 408), "07", new float[]{1, 0, 0}, 1, true), new NamedWaypoint(new BlockPos(495, 34, 418), "11", new float[]{1, 0, 0}, 1, true), @@ -127,18 +127,18 @@ void testFromSkytilsBase64CrystalHollowsWaypoints() { new NamedWaypoint(new BlockPos(497, 55, 391), "21", new float[]{1, 0, 0}, 1, true) ))); - Assertions.assertEquals(expectedWaypointCategories, waypointCategories); + Assertions.assertEquals(expectedWaypointGroups, waypointGroups); } @Test void testFromSkytilsV1Gzip() { String waypointsSkytilsV1Gzip = "(V1):H4sIAAAAAAAC/51STWuEMBD9KyHntJjJl7u3UugfsIdC2UOq6SKk0cZIaxf/e+OC4moL4i2TmXnvzby54FwHc658aRp8RK8X7PSHiS+ctXVtO5Tpd4OyugoNJvhLd3VVurAs/Wy1NzH/HaM7yinBXXwpSfDP8HNICDZOv1lTxDD41hCsi8IUDyHGVCp+4JLGPi57MoMN2gf07EvtznaCl+kCnQJsgGeRgfM5/BJ4UHkFVhNwukm34sD6E8FlY7UbKnHpmqBdHtvmhE+tsejRWLtpqaM8BPfJKDGlS4mMrSXmla38NSu4lDDYsVItEg5ws46XyT8QKxa5j4UBCEhuPN1xKluYIBVUsZt55oujbJxJTObu3BxPmAL51yGhkU2tL4nuJBMCgP57XKf+FzPhnyPAAwAA"; - List waypointCategories = Waypoints.fromSkytils(waypointsSkytilsV1Gzip, "default_island"); - List expectedWaypointCategories = List.of(new WaypointCategory("Supply Safe Spots", "default_island", List.of( + List waypointGroups = Waypoints.fromSkytils(waypointsSkytilsV1Gzip, "default_island"); + List expectedWaypointGroups = List.of(new WaypointGroup("Supply Safe Spots", "default_island", List.of( new NamedWaypoint(new BlockPos(-141, 76, -90), "Square", new float[]{0, 1, 0}, 128 / 255f, true), new NamedWaypoint(new BlockPos(-68, 76, -122), "Start Triangle", new float[]{0, 1, 0}, 128 / 255f, true), new NamedWaypoint(new BlockPos(-90, 77, -128), "Triangle", new float[]{0, 1, 0}, 128 / 255f, true) - )), new WaypointCategory("Fuel Cell Safe Spots", "default_island", List.of( + )), new WaypointGroup("Fuel Cell Safe Spots", "default_island", List.of( new NamedWaypoint(new BlockPos(-81, 77, -133), "Triangle 2.0", new float[]{20 / 255f, 0, 1}, 1, true), new NamedWaypoint(new BlockPos(-125, 77, -136), "X", new float[]{20 / 255f, 0, 1}, 1, true), new NamedWaypoint(new BlockPos(-141, 76, -90), "Square", new float[]{20 / 255f, 0, 1}, 1, true), @@ -146,14 +146,14 @@ void testFromSkytilsV1Gzip() { new NamedWaypoint(new BlockPos(-70, 77, -121), "Triangle ", new float[]{20 / 255f, 0, 1}, 1, true) ))); - Assertions.assertEquals(expectedWaypointCategories, waypointCategories); + Assertions.assertEquals(expectedWaypointGroups, waypointGroups); } @Test void testFromColeweightJson() { String coleweightJson = "[{\"x\":64,\"y\":78,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":45,\"y\":79,\"z\":49,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":60,\"y\":76,\"z\":51,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":63,\"y\":76,\"z\":95,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":63,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":94,\"y\":77,\"z\":42,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":91,\"y\":77,\"z\":27,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":50,\"y\":80,\"z\":88,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":50,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":58,\"y\":79,\"z\":89,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":78,\"y\":74,\"z\":99,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":46,\"y\":80,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":97,\"y\":81,\"z\":77,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":55,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":39,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":95,\"y\":76,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":97,\"y\":75,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":45,\"y\":79,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":75,\"y\":82,\"z\":20,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":36,\"y\":80,\"z\":80,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":43,\"y\":77,\"z\":50,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":43,\"y\":79,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":35,\"y\":8,\"z\":71,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":89,\"y\":77,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":73,\"y\":76,\"z\":31,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":47,\"y\":77,\"z\":65,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":52,\"y\":75,\"z\":45,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":82,\"y\":78,\"z\":26,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":61,\"y\":78,\"z\":92,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":73,\"y\":79,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":103,\"y\":74,\"z\":98,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":104,\"y\":78,\"z\":68,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":42,\"y\":77,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":41,\"y\":79,\"z\":81,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":90,\"y\":77,\"z\":46,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":32,\"y\":80,\"z\":74,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":78,\"y\":77,\"z\":40,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":76,\"y\":76,\"z\":55,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":66,\"y\":81,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":90,\"y\":77,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":55,\"y\":80,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":92,\"y\":74,\"z\":108,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":50,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":98,\"y\":77,\"z\":76,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":79,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":91,\"y\":76,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":98,\"y\":78,\"z\":75,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}}]"; - WaypointCategory waypointCategory = Waypoints.fromColeweightJson(coleweightJson, "winter"); - WaypointCategory expectedWaypointCategory = new WaypointCategory("Coleweight", "winter", List.of( + WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, "winter"); + WaypointGroup expectedWaypointGroup = new WaypointGroup("Coleweight", "winter", List.of( new OrderedNamedWaypoint(new BlockPos(64, 78, 28), "24", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(45, 79, 49), "9", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(60, 76, 51), "20", new float[]{0, 1, 0}), @@ -203,21 +203,21 @@ void testFromColeweightJson() { new OrderedNamedWaypoint(new BlockPos(98, 78, 75), "45", new float[]{0, 1, 0}) ), true); - Assertions.assertEquals(expectedWaypointCategory.waypoints().size(), waypointCategory.waypoints().size()); - for (int i = 0; i < waypointCategory.waypoints().size(); i++) { - Assertions.assertEquals(expectedWaypointCategory.waypoints().get(i), waypointCategory.waypoints().get(i)); + Assertions.assertEquals(expectedWaypointGroup.waypoints().size(), waypointGroup.waypoints().size()); + for (int i = 0; i < waypointGroup.waypoints().size(); i++) { + Assertions.assertEquals(expectedWaypointGroup.waypoints().get(i), waypointGroup.waypoints().get(i)); } - Assertions.assertEquals(expectedWaypointCategory.name(), waypointCategory.name()); - Assertions.assertEquals(expectedWaypointCategory.island(), waypointCategory.island()); - Assertions.assertEquals(expectedWaypointCategory.ordered(), waypointCategory.ordered()); - Assertions.assertEquals(expectedWaypointCategory, waypointCategory); + Assertions.assertEquals(expectedWaypointGroup.name(), waypointGroup.name()); + Assertions.assertEquals(expectedWaypointGroup.island(), waypointGroup.island()); + Assertions.assertEquals(expectedWaypointGroup.ordered(), waypointGroup.ordered()); + Assertions.assertEquals(expectedWaypointGroup, waypointGroup); } @Test void testFromColeweightJsonSapphire() { String coleweightJson = "[{\"x\":821,\"y\":137,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":821,\"y\":143,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":812,\"y\":154,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":817,\"y\":159,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":814,\"y\":168,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":814,\"y\":171,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":810,\"y\":177,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":803,\"y\":183,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":802,\"y\":178,\"z\":817,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":803,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":800,\"y\":167,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":787,\"y\":174,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":783,\"y\":177,\"z\":820,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":766,\"y\":177,\"z\":822,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":769,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":775,\"y\":170,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":778,\"y\":161,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":787,\"y\":155,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":778,\"y\":153,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":789,\"y\":154,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":794,\"y\":159,\"z\":823,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":804,\"y\":163,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":794,\"y\":164,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":801,\"y\":168,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":806,\"y\":161,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":801,\"y\":157,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":791,\"y\":161,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":796,\"y\":164,\"z\":776,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":798,\"y\":167,\"z\":774,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":803,\"y\":161,\"z\":764,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":810,\"y\":159,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":817,\"y\":156,\"z\":767,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":821,\"y\":149,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":814,\"y\":139,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":818,\"y\":137,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":818,\"y\":143,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":802,\"y\":140,\"z\":739,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":804,\"y\":131,\"z\":730,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":792,\"y\":121,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":788,\"y\":127,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":792,\"y\":127,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":783,\"y\":123,\"z\":731,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":786,\"y\":122,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":785,\"y\":124,\"z\":707,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":769,\"y\":129,\"z\":709,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}},{\"x\":764,\"y\":131,\"z\":716,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":757,\"y\":131,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":755,\"y\":139,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"48\"}},{\"x\":753,\"y\":134,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"49\"}},{\"x\":768,\"y\":126,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"50\"}},{\"x\":770,\"y\":122,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"51\"}},{\"x\":777,\"y\":116,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"52\"}},{\"x\":779,\"y\":113,\"z\":725,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"53\"}},{\"x\":786,\"y\":116,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"54\"}},{\"x\":783,\"y\":123,\"z\":752,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"55\"}},{\"x\":778,\"y\":125,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"56\"}},{\"x\":784,\"y\":131,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"57\"}},{\"x\":789,\"y\":135,\"z\":760,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"58\"}},{\"x\":792,\"y\":138,\"z\":758,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"59\"}},{\"x\":802,\"y\":138,\"z\":769,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"60\"}},{\"x\":807,\"y\":142,\"z\":780,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"61\"}},{\"x\":805,\"y\":132,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"62\"}},{\"x\":820,\"y\":123,\"z\":772,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"63\"}},{\"x\":813,\"y\":131,\"z\":766,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"64\"}},{\"x\":812,\"y\":127,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"65\"}},{\"x\":804,\"y\":126,\"z\":753,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"66\"}},{\"x\":810,\"y\":125,\"z\":750,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"67\"}},{\"x\":821,\"y\":127,\"z\":751,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"68\"}},{\"x\":815,\"y\":124,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"69\"}},{\"x\":815,\"y\":120,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"70\"}},{\"x\":806,\"y\":115,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"71\"}},{\"x\":796,\"y\":125,\"z\":741,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"72\"}},{\"x\":798,\"y\":119,\"z\":757,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"73\"}},{\"x\":799,\"y\":112,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"74\"}},{\"x\":783,\"y\":110,\"z\":765,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"75\"}},{\"x\":804,\"y\":116,\"z\":777,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"76\"}},{\"x\":801,\"y\":116,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"77\"}},{\"x\":793,\"y\":110,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"78\"}},{\"x\":795,\"y\":107,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"79\"}},{\"x\":805,\"y\":100,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"80\"}},{\"x\":821,\"y\":105,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"81\"}},{\"x\":818,\"y\":96,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"82\"}},{\"x\":803,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"83\"}},{\"x\":793,\"y\":97,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"84\"}},{\"x\":791,\"y\":94,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"85\"}},{\"x\":787,\"y\":94,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"86\"}},{\"x\":775,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"87\"}},{\"x\":771,\"y\":91,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"88\"}},{\"x\":763,\"y\":89,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"89\"}},{\"x\":768,\"y\":101,\"z\":806,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"90\"}},{\"x\":785,\"y\":105,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"91\"}},{\"x\":791,\"y\":101,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"92\"}},{\"x\":791,\"y\":103,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"93\"}},{\"x\":771,\"y\":102,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"94\"}},{\"x\":764,\"y\":99,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"95\"}},{\"x\":758,\"y\":97,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"96\"}},{\"x\":762,\"y\":93,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"97\"}},{\"x\":778,\"y\":92,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"98\"}},{\"x\":786,\"y\":90,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"99\"}},{\"x\":790,\"y\":88,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"100\"}},{\"x\":792,\"y\":82,\"z\":815,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"101\"}},{\"x\":783,\"y\":76,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"102\"}},{\"x\":795,\"y\":69,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"103\"}},{\"x\":800,\"y\":66,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"104\"}},{\"x\":810,\"y\":65,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"105\"}},{\"x\":817,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"106\"}},{\"x\":815,\"y\":75,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"107\"}},{\"x\":822,\"y\":85,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"108\"}},{\"x\":822,\"y\":85,\"z\":785,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"109\"}},{\"x\":811,\"y\":88,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"110\"}},{\"x\":804,\"y\":86,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"111\"}},{\"x\":792,\"y\":78,\"z\":790,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"112\"}},{\"x\":790,\"y\":77,\"z\":793,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"113\"}},{\"x\":785,\"y\":68,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"114\"}},{\"x\":773,\"y\":75,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"115\"}},{\"x\":773,\"y\":78,\"z\":794,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"116\"}},{\"x\":757,\"y\":83,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"117\"}},{\"x\":742,\"y\":84,\"z\":791,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"118\"}},{\"x\":737,\"y\":85,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"119\"}},{\"x\":731,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"120\"}},{\"x\":731,\"y\":81,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"121\"}},{\"x\":743,\"y\":82,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"122\"}},{\"x\":746,\"y\":96,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"123\"}},{\"x\":742,\"y\":110,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"124\"}},{\"x\":745,\"y\":110,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"125\"}},{\"x\":752,\"y\":113,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"126\"}},{\"x\":742,\"y\":123,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"127\"}},{\"x\":736,\"y\":129,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"128\"}},{\"x\":733,\"y\":138,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"129\"}},{\"x\":737,\"y\":134,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"130\"}},{\"x\":741,\"y\":131,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"131\"}},{\"x\":743,\"y\":129,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"132\"}},{\"x\":753,\"y\":134,\"z\":804,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"133\"}},{\"x\":755,\"y\":139,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"134\"}},{\"x\":757,\"y\":131,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"135\"}},{\"x\":772,\"y\":140,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"136\"}},{\"x\":773,\"y\":144,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"137\"}},{\"x\":784,\"y\":142,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"138\"}},{\"x\":785,\"y\":141,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"139\"}},{\"x\":793,\"y\":147,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"140\"}},{\"x\":785,\"y\":137,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"141\"}},{\"x\":790,\"y\":133,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"142\"}},{\"x\":806,\"y\":131,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"143\"}},{\"x\":803,\"y\":131,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"144\"}}]"; - WaypointCategory waypointCategory = Waypoints.fromColeweightJson(coleweightJson, "crystal_hollows"); - WaypointCategory expectedWaypointCategory = new WaypointCategory("Coleweight", "crystal_hollows", List.of( + WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, "crystal_hollows"); + WaypointGroup expectedWaypointGroup = new WaypointGroup("Coleweight", "crystal_hollows", List.of( new OrderedNamedWaypoint(new BlockPos(821, 137, 809), "1", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(821, 143, 809), "2", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(812, 154, 798), "3", new float[]{0, 1, 0}), @@ -364,13 +364,13 @@ void testFromColeweightJsonSapphire() { new OrderedNamedWaypoint(new BlockPos(803, 131, 809), "144", new float[]{0, 1, 0}) ), true); - Assertions.assertEquals(expectedWaypointCategory.waypoints().size(), waypointCategory.waypoints().size()); - for (int i = 0; i < waypointCategory.waypoints().size(); i++) { - Assertions.assertEquals(expectedWaypointCategory.waypoints().get(i), waypointCategory.waypoints().get(i)); + Assertions.assertEquals(expectedWaypointGroup.waypoints().size(), waypointGroup.waypoints().size()); + for (int i = 0; i < waypointGroup.waypoints().size(); i++) { + Assertions.assertEquals(expectedWaypointGroup.waypoints().get(i), waypointGroup.waypoints().get(i)); } - Assertions.assertEquals(expectedWaypointCategory.name(), waypointCategory.name()); - Assertions.assertEquals(expectedWaypointCategory.island(), waypointCategory.island()); - Assertions.assertEquals(expectedWaypointCategory.ordered(), waypointCategory.ordered()); - Assertions.assertEquals(expectedWaypointCategory, waypointCategory); + Assertions.assertEquals(expectedWaypointGroup.name(), waypointGroup.name()); + Assertions.assertEquals(expectedWaypointGroup.island(), waypointGroup.island()); + Assertions.assertEquals(expectedWaypointGroup.ordered(), waypointGroup.ordered()); + Assertions.assertEquals(expectedWaypointGroup, waypointGroup); } } From 3ec2859c35a55ed4f6e93c1173fc438c240f1f1a Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:07:30 -0400 Subject: [PATCH 06/18] Add skyblocker format --- .../skyblock/waypoint/OrderedWaypoints.java | 2 +- .../skyblock/waypoint/Waypoints.java | 62 +++- .../waypoint/WaypointsShareScreen.java | 46 ++- .../utils/waypoint/NamedWaypoint.java | 8 +- .../assets/skyblocker/lang/en_us.json | 4 + .../utils/waypoint/WaypointsTest.java | 326 +++++++++--------- 6 files changed, 253 insertions(+), 195 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index 687c815f08..6d87310d11 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -62,7 +62,7 @@ public class OrderedWaypoints { private static final Logger LOGGER = LogUtils.getLogger(); private static final Codec> SERIALIZATION_CODEC = Codec.unboundedMap(Codec.STRING, OrderedWaypointGroup.CODEC).xmap(Object2ObjectOpenHashMap::new, Object2ObjectOpenHashMap::new); private static final String PREFIX = "[Skyblocker::OrderedWaypoints::v1]"; - private static final Path PATH = SkyblockerMod.CONFIG_DIR.resolve("ordered_waypoints.json"); + public static final Path PATH = SkyblockerMod.CONFIG_DIR.resolve("ordered_waypoints.json"); private static final Map WAYPOINTS = new Object2ObjectOpenHashMap<>(); private static final Semaphore SEMAPHORE = new Semaphore(1); private static final Object2IntOpenHashMap INDEX_STORE = new Object2IntOpenHashMap<>(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java index ecceefa125..3e873d215f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java @@ -24,18 +24,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; +import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Base64; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; @@ -43,6 +41,7 @@ public class Waypoints { public static final Logger LOGGER = LoggerFactory.getLogger(Waypoints.class); private static final Codec> CODEC = WaypointGroup.CODEC.listOf(); private static final Codec> SKYTILS_CODEC = WaypointGroup.SKYTILS_CODEC.listOf(); + private static final String PREFIX = "[Skyblocker-Waypoint-Data-V1]"; protected static final SystemToast.Type WAYPOINTS_TOAST_TYPE = new SystemToast.Type(); private static final Path waypointsFile = FabricLoader.getInstance().getConfigDir().resolve(SkyblockerMod.NAMESPACE).resolve("waypoints.json"); @@ -59,13 +58,45 @@ public static void init() { public static void loadWaypoints() { waypoints.clear(); try (BufferedReader reader = Files.newBufferedReader(waypointsFile)) { - List waypoints = CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(reader, JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow(); - waypoints.forEach(waypointGroup -> Waypoints.waypoints.put(waypointGroup.island(), waypointGroup)); + List waypointGroups = CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(reader, JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow(); + waypointGroups.forEach(waypointGroup -> waypoints.put(waypointGroup.island(), waypointGroup)); } catch (Exception e) { LOGGER.error("[Skyblocker Waypoints] Encountered exception while loading waypoints", e); } } + public static void saveWaypoints(MinecraftClient client) { + try (BufferedWriter writer = Files.newBufferedWriter(waypointsFile)) { + JsonElement waypointsJson = CODEC.encodeStart(JsonOps.INSTANCE, List.copyOf(waypoints.values())).resultOrPartial(LOGGER::error).orElseThrow(); + SkyblockerMod.GSON.toJson(waypointsJson, writer); + LOGGER.info("[Skyblocker Waypoints] Saved waypoints"); + } catch (Exception e) { + LOGGER.error("[Skyblocker Waypoints] Encountered exception while saving waypoints", e); + } + } + + public static List fromSkyblocker(String waypointsString) { + if (waypointsString.startsWith(PREFIX)) { + try (GZIPInputStream reader = new GZIPInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(waypointsString.replace(PREFIX, ""))))) { + return CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(new String(reader.readAllBytes()), JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow(); + } catch (IOException e) { + LOGGER.error("[Skyblocker Waypoints] Encountered exception while parsing Skyblocker waypoint data", e); + } + } + return Collections.emptyList(); + } + + public static String toSkyblocker(List waypointGroups) { + String waypointsJson = SkyblockerMod.GSON.toJson(CODEC.encodeStart(JsonOps.INSTANCE, waypointGroups).resultOrPartial(LOGGER::error).orElseThrow()); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try (GZIPOutputStream gzip = new GZIPOutputStream(output)){ + gzip.write(waypointsJson.getBytes()); + } catch (IOException e) { + LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skyblocker waypoint data", e); + } + return PREFIX + new String(Base64.getEncoder().encode(output.toByteArray())); + } + public static List fromSkytils(String waypointsString, String defaultIsland) { try { if (waypointsString.startsWith("(V")) { @@ -118,24 +149,19 @@ public static WaypointGroup fromColeweightJson(String waypointsJson, String defa return WaypointGroup.COLEWEIGHT_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(waypointsJson)).resultOrPartial(LOGGER::error).orElseThrow().withIsland(defaultIsland); } - public static void saveWaypoints(MinecraftClient client) { - try (BufferedWriter writer = Files.newBufferedWriter(waypointsFile)) { - JsonElement waypointsJson = CODEC.encodeStart(JsonOps.INSTANCE, List.copyOf(waypoints.values())).resultOrPartial(LOGGER::error).orElseThrow(); - SkyblockerMod.GSON.toJson(waypointsJson, writer); - LOGGER.info("[Skyblocker Waypoints] Saved waypoints"); - } catch (Exception e) { - LOGGER.error("[Skyblocker Waypoints] Encountered exception while saving waypoints", e); - } - } - public static Multimap waypointsDeepCopy() { return waypoints.values().stream().map(WaypointGroup::deepCopy).collect(Multimaps.toMultimap(WaypointGroup::island, Function.identity(), () -> MultimapBuilder.hashKeys().arrayListValues().build())); } public static void render(WorldRenderContext context) { if (SkyblockerConfigManager.get().uiAndVisuals.waypoints.enableWaypoints) { - Collection groups = waypoints.get(Utils.getLocationRaw()); - for (WaypointGroup group : groups) { + for (WaypointGroup group : waypoints.get(Utils.getLocationRaw())) { + if (group != null) { + group.render(context); + } + } + if (Utils.getLocationRaw().isEmpty()) return; + for (WaypointGroup group : waypoints.get("")) { if (group != null) { group.render(context); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index 51967a761f..5b288090c2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -29,6 +29,30 @@ protected void init() { GridWidget gridWidget = new GridWidget(); gridWidget.getMainPositioner().marginX(5).marginY(2); GridWidget.Adder adder = gridWidget.createAdder(2); + adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSkyblocker"), buttonImport -> { + try { + List waypointGroups = Waypoints.fromSkyblocker(client.keyboard.getClipboard()); + for (WaypointGroup waypointGroup : waypointGroups) { + selectedWaypoints.addAll(waypointGroup.waypoints()); + waypoints.put(waypointGroup.island(), waypointGroup); + } + waypointsListWidget.updateEntries(); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importSuccess"), Text.translatable("skyblocker.waypoints.importSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); + } catch (Exception e) { + Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while parsing Skyblocker waypoint data", e); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); + } + }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkyblocker.tooltip"))).build()); + adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkyblocker"), buttonExport -> { + try { + List waypointGroups = waypoints.values().stream().filter(waypointGroup -> waypointGroup.island().equals(island)).map(waypointGroup -> waypointGroup.filterWaypoints(selectedWaypoints::contains)).filter(waypointGroup -> !waypointGroup.waypoints().isEmpty()).toList(); + client.keyboard.setClipboard(Waypoints.toSkyblocker(waypointGroups)); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); + } catch (Exception e) { + Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skyblocker waypoint data", e); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportError"), Text.translatable("skyblocker.waypoints.exportErrorText")); + } + }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkyblocker.tooltip"))).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSkytils"), buttonImport -> { try { List waypointGroups = Waypoints.fromSkytils(client.keyboard.getClipboard(), island); @@ -43,6 +67,16 @@ protected void init() { SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); } }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkytils.tooltip"))).build()); + adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils"), buttonExport -> { + try { + List waypointGroups = waypoints.values().stream().filter(waypointGroup -> waypointGroup.island().equals(island)).map(waypointGroup -> waypointGroup.filterWaypoints(selectedWaypoints::contains)).filter(waypointGroup -> !waypointGroup.waypoints().isEmpty()).toList(); + client.keyboard.setClipboard(Waypoints.toSkytilsBase64(waypointGroups)); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); + } catch (Exception e) { + Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skytils waypoint data", e); + SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportError"), Text.translatable("skyblocker.waypoints.exportErrorText")); + } + }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils.tooltip"))).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy"), buttonImport -> { try { WaypointGroup waypointGroup = Waypoints.fromColeweightJson(client.keyboard.getClipboard(), island); @@ -55,17 +89,7 @@ protected void init() { SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.importError"), Text.translatable("skyblocker.waypoints.importErrorText")); } }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy.tooltip"))).build()); - adder.add(ButtonWidget.builder(ScreenTexts.BACK, buttonBack -> close()).build()); - adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils"), buttonExport -> { - try { - List waypointGroups = waypoints.values().stream().filter(waypointGroup -> waypointGroup.island().equals(island)).map(waypointGroup -> waypointGroup.filterWaypoints(selectedWaypoints::contains)).filter(waypointGroup -> !waypointGroup.waypoints().isEmpty()).toList(); - client.keyboard.setClipboard(Waypoints.toSkytilsBase64(waypointGroups)); - SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportSuccess"), Text.translatable("skyblocker.waypoints.exportSuccessText", waypointGroups.stream().map(WaypointGroup::waypoints).mapToInt(List::size).sum(), waypointGroups.size())); - } catch (Exception e) { - Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skytils waypoint data", e); - SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportError"), Text.translatable("skyblocker.waypoints.exportErrorText")); - } - }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.exportWaypointsSkytils.tooltip"))).build()); + adder.add(ButtonWidget.builder(ScreenTexts.DONE, buttonBack -> close()).build()); gridWidget.refreshPositions(); SimplePositioningWidget.setPos(gridWidget, 0, this.height - 64, this.width, 64); gridWidget.forEachChild(this::addDrawableChild); diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index a199c1bde1..5f5d46a820 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -22,13 +22,13 @@ public class NamedWaypoint extends Waypoint { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - BlockPos.CODEC.fieldOf("pos").forGetter(secretWaypoint -> secretWaypoint.pos), - TextCodecs.CODEC.fieldOf("name").forGetter(secretWaypoint -> secretWaypoint.name), + BlockPos.CODEC.fieldOf("pos").forGetter(waypoint -> waypoint.pos), + TextCodecs.CODEC.fieldOf("name").forGetter(waypoint -> waypoint.name), Codec.floatRange(0, 1).listOf().comapFlatMap( colorComponentsList -> colorComponentsList.size() == 3 ? DataResult.success(Floats.toArray(colorComponentsList)) : DataResult.error(() -> "Expected 3 color components, got " + colorComponentsList.size() + " instead"), Floats::asList - ).fieldOf("colorComponents").forGetter(secretWaypoint -> secretWaypoint.colorComponents), - Codec.FLOAT.fieldOf("alpha").forGetter(secretWaypoint -> secretWaypoint.alpha), + ).fieldOf("colorComponents").forGetter(waypoint -> waypoint.colorComponents), + Codec.FLOAT.fieldOf("alpha").forGetter(waypoint -> waypoint.alpha), Codec.BOOL.fieldOf("shouldRender").forGetter(Waypoint::isEnabled) ).apply(instance, NamedWaypoint::new)); public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 89edb22e29..31e8093fdb 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -954,6 +954,10 @@ "skyblocker.waypoints.new": "New Waypoint", "skyblocker.waypoints.share": "Share", "skyblocker.waypoints.shareWaypoints": "Share Waypoints", + "skyblocker.waypoints.importWaypointsSkyblocker": "Import Waypoints (Skyblocker)", + "skyblocker.waypoints.importWaypointsSkyblocker.tooltip": "Import Waypoints from Clipboard (Skyblocker Format)", + "skyblocker.waypoints.exportWaypointsSkyblocker": "Export Waypoints (Skyblocker)", + "skyblocker.waypoints.exportWaypointsSkyblocker.tooltip": "Export Waypoints from Clipboard (Skyblocker Format)", "skyblocker.waypoints.importWaypointsSkytils": "Import Waypoints (Skytils)", "skyblocker.waypoints.importWaypointsSkytils.tooltip": "Import Waypoints from Clipboard (Skytils Format)", "skyblocker.waypoints.importWaypointsSnoopy": "Import Waypoints (Snoopy)", diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java index 83ad6eba6c..40cfd73593 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java @@ -11,6 +11,153 @@ import java.util.List; public class WaypointsTest { + private static final WaypointGroup SAPPHIRE_WAYOINTS = new WaypointGroup("Coleweight", "crystal_hollows", List.of( + new OrderedNamedWaypoint(new BlockPos(821, 137, 809), "1", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 143, 809), "2", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(812, 154, 798), "3", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 159, 803), "4", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 168, 798), "5", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 171, 809), "6", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 177, 821), "7", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 183, 821), "8", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 178, 817), "9", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 175, 811), "10", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(800, 167, 799), "11", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 174, 809), "12", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 177, 820), "13", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(766, 177, 822), "14", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(769, 175, 811), "15", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(775, 170, 810), "16", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 161, 800), "17", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 155, 792), "18", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 153, 801), "19", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(789, 154, 809), "20", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(794, 159, 823), "21", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 163, 816), "22", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(794, 164, 800), "23", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 168, 795), "24", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 161, 783), "25", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 157, 778), "26", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 161, 781), "27", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(796, 164, 776), "28", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(798, 167, 774), "29", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 161, 764), "30", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 159, 762), "31", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 156, 767), "32", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 149, 754), "33", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(814, 139, 742), "34", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 137, 736), "35", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 143, 736), "36", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 140, 739), "37", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 131, 730), "38", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 121, 726), "39", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(788, 127, 727), "40", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 127, 726), "41", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 123, 731), "42", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 122, 717), "43", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 124, 707), "44", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(769, 129, 709), "45", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(764, 131, 716), "46", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 131, 717), "47", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(755, 139, 727), "48", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(753, 134, 723), "49", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(768, 126, 723), "50", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(770, 122, 720), "51", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(777, 116, 720), "52", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(779, 113, 725), "53", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 116, 742), "54", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 123, 752), "55", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 125, 762), "56", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(784, 131, 754), "57", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(789, 135, 760), "58", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 138, 758), "59", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(802, 138, 769), "60", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(807, 142, 780), "61", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(805, 132, 775), "62", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(820, 123, 772), "63", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(813, 131, 766), "64", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(812, 127, 763), "65", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 126, 753), "66", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 125, 750), "67", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 127, 751), "68", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 124, 742), "69", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 120, 732), "70", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 115, 732), "71", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(796, 125, 741), "72", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(798, 119, 757), "73", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(799, 112, 763), "74", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 110, 765), "75", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 116, 777), "76", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(801, 116, 788), "77", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 110, 798), "78", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(795, 107, 800), "79", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(805, 100, 803), "80", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(821, 105, 809), "81", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(818, 96, 816), "82", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 92, 802), "83", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 97, 813), "84", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 94, 809), "85", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(787, 94, 810), "86", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(775, 92, 802), "87", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(771, 91, 799), "88", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(763, 89, 805), "89", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(768, 101, 806), "90", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 105, 808), "91", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 101, 805), "92", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(791, 103, 784), "93", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(771, 102, 778), "94", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(764, 99, 781), "95", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(758, 97, 792), "96", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(762, 93, 783), "97", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(778, 92, 775), "98", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(786, 90, 784), "99", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 88, 792), "100", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 82, 815), "101", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(783, 76, 811), "102", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(795, 69, 821), "103", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(800, 66, 807), "104", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(810, 65, 811), "105", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(817, 75, 813), "106", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(815, 75, 800), "107", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(822, 85, 800), "108", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(822, 85, 785), "109", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(811, 88, 778), "110", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(804, 86, 792), "111", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(792, 78, 790), "112", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 77, 793), "113", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 68, 800), "114", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 75, 797), "115", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 78, 794), "116", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 83, 797), "117", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 84, 791), "118", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(737, 85, 797), "119", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(731, 75, 813), "120", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(731, 81, 816), "121", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(743, 82, 821), "122", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(746, 96, 798), "123", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 110, 788), "124", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(745, 110, 807), "125", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(752, 113, 805), "126", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(742, 123, 801), "127", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(736, 129, 801), "128", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(733, 138, 795), "129", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(737, 134, 792), "130", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(741, 131, 799), "131", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(743, 129, 802), "132", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(753, 134, 804), "133", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(755, 139, 808), "134", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(757, 131, 798), "135", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(772, 140, 803), "136", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(773, 144, 797), "137", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(784, 142, 797), "138", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 141, 795), "139", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(793, 147, 801), "140", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(785, 137, 810), "141", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(790, 133, 800), "142", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(806, 131, 803), "143", new float[]{0, 1, 0}), + new OrderedNamedWaypoint(new BlockPos(803, 131, 809), "144", new float[]{0, 1, 0}) + ), true); + @BeforeAll public static void setup() { SharedConstants.createGameVersion(); @@ -203,13 +350,6 @@ void testFromColeweightJson() { new OrderedNamedWaypoint(new BlockPos(98, 78, 75), "45", new float[]{0, 1, 0}) ), true); - Assertions.assertEquals(expectedWaypointGroup.waypoints().size(), waypointGroup.waypoints().size()); - for (int i = 0; i < waypointGroup.waypoints().size(); i++) { - Assertions.assertEquals(expectedWaypointGroup.waypoints().get(i), waypointGroup.waypoints().get(i)); - } - Assertions.assertEquals(expectedWaypointGroup.name(), waypointGroup.name()); - Assertions.assertEquals(expectedWaypointGroup.island(), waypointGroup.island()); - Assertions.assertEquals(expectedWaypointGroup.ordered(), waypointGroup.ordered()); Assertions.assertEquals(expectedWaypointGroup, waypointGroup); } @@ -217,160 +357,24 @@ void testFromColeweightJson() { void testFromColeweightJsonSapphire() { String coleweightJson = "[{\"x\":821,\"y\":137,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":821,\"y\":143,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":812,\"y\":154,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":817,\"y\":159,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":814,\"y\":168,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":814,\"y\":171,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":810,\"y\":177,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":803,\"y\":183,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":802,\"y\":178,\"z\":817,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":803,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":800,\"y\":167,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":787,\"y\":174,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":783,\"y\":177,\"z\":820,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":766,\"y\":177,\"z\":822,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":769,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":775,\"y\":170,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":778,\"y\":161,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":787,\"y\":155,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":778,\"y\":153,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":789,\"y\":154,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":794,\"y\":159,\"z\":823,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":804,\"y\":163,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":794,\"y\":164,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":801,\"y\":168,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":806,\"y\":161,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":801,\"y\":157,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":791,\"y\":161,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":796,\"y\":164,\"z\":776,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":798,\"y\":167,\"z\":774,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":803,\"y\":161,\"z\":764,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":810,\"y\":159,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":817,\"y\":156,\"z\":767,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":821,\"y\":149,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":814,\"y\":139,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":818,\"y\":137,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":818,\"y\":143,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":802,\"y\":140,\"z\":739,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":804,\"y\":131,\"z\":730,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":792,\"y\":121,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":788,\"y\":127,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":792,\"y\":127,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":783,\"y\":123,\"z\":731,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":786,\"y\":122,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":785,\"y\":124,\"z\":707,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":769,\"y\":129,\"z\":709,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}},{\"x\":764,\"y\":131,\"z\":716,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":757,\"y\":131,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":755,\"y\":139,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"48\"}},{\"x\":753,\"y\":134,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"49\"}},{\"x\":768,\"y\":126,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"50\"}},{\"x\":770,\"y\":122,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"51\"}},{\"x\":777,\"y\":116,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"52\"}},{\"x\":779,\"y\":113,\"z\":725,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"53\"}},{\"x\":786,\"y\":116,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"54\"}},{\"x\":783,\"y\":123,\"z\":752,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"55\"}},{\"x\":778,\"y\":125,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"56\"}},{\"x\":784,\"y\":131,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"57\"}},{\"x\":789,\"y\":135,\"z\":760,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"58\"}},{\"x\":792,\"y\":138,\"z\":758,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"59\"}},{\"x\":802,\"y\":138,\"z\":769,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"60\"}},{\"x\":807,\"y\":142,\"z\":780,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"61\"}},{\"x\":805,\"y\":132,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"62\"}},{\"x\":820,\"y\":123,\"z\":772,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"63\"}},{\"x\":813,\"y\":131,\"z\":766,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"64\"}},{\"x\":812,\"y\":127,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"65\"}},{\"x\":804,\"y\":126,\"z\":753,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"66\"}},{\"x\":810,\"y\":125,\"z\":750,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"67\"}},{\"x\":821,\"y\":127,\"z\":751,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"68\"}},{\"x\":815,\"y\":124,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"69\"}},{\"x\":815,\"y\":120,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"70\"}},{\"x\":806,\"y\":115,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"71\"}},{\"x\":796,\"y\":125,\"z\":741,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"72\"}},{\"x\":798,\"y\":119,\"z\":757,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"73\"}},{\"x\":799,\"y\":112,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"74\"}},{\"x\":783,\"y\":110,\"z\":765,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"75\"}},{\"x\":804,\"y\":116,\"z\":777,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"76\"}},{\"x\":801,\"y\":116,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"77\"}},{\"x\":793,\"y\":110,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"78\"}},{\"x\":795,\"y\":107,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"79\"}},{\"x\":805,\"y\":100,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"80\"}},{\"x\":821,\"y\":105,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"81\"}},{\"x\":818,\"y\":96,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"82\"}},{\"x\":803,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"83\"}},{\"x\":793,\"y\":97,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"84\"}},{\"x\":791,\"y\":94,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"85\"}},{\"x\":787,\"y\":94,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"86\"}},{\"x\":775,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"87\"}},{\"x\":771,\"y\":91,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"88\"}},{\"x\":763,\"y\":89,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"89\"}},{\"x\":768,\"y\":101,\"z\":806,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"90\"}},{\"x\":785,\"y\":105,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"91\"}},{\"x\":791,\"y\":101,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"92\"}},{\"x\":791,\"y\":103,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"93\"}},{\"x\":771,\"y\":102,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"94\"}},{\"x\":764,\"y\":99,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"95\"}},{\"x\":758,\"y\":97,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"96\"}},{\"x\":762,\"y\":93,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"97\"}},{\"x\":778,\"y\":92,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"98\"}},{\"x\":786,\"y\":90,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"99\"}},{\"x\":790,\"y\":88,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"100\"}},{\"x\":792,\"y\":82,\"z\":815,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"101\"}},{\"x\":783,\"y\":76,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"102\"}},{\"x\":795,\"y\":69,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"103\"}},{\"x\":800,\"y\":66,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"104\"}},{\"x\":810,\"y\":65,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"105\"}},{\"x\":817,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"106\"}},{\"x\":815,\"y\":75,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"107\"}},{\"x\":822,\"y\":85,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"108\"}},{\"x\":822,\"y\":85,\"z\":785,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"109\"}},{\"x\":811,\"y\":88,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"110\"}},{\"x\":804,\"y\":86,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"111\"}},{\"x\":792,\"y\":78,\"z\":790,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"112\"}},{\"x\":790,\"y\":77,\"z\":793,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"113\"}},{\"x\":785,\"y\":68,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"114\"}},{\"x\":773,\"y\":75,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"115\"}},{\"x\":773,\"y\":78,\"z\":794,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"116\"}},{\"x\":757,\"y\":83,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"117\"}},{\"x\":742,\"y\":84,\"z\":791,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"118\"}},{\"x\":737,\"y\":85,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"119\"}},{\"x\":731,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"120\"}},{\"x\":731,\"y\":81,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"121\"}},{\"x\":743,\"y\":82,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"122\"}},{\"x\":746,\"y\":96,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"123\"}},{\"x\":742,\"y\":110,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"124\"}},{\"x\":745,\"y\":110,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"125\"}},{\"x\":752,\"y\":113,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"126\"}},{\"x\":742,\"y\":123,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"127\"}},{\"x\":736,\"y\":129,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"128\"}},{\"x\":733,\"y\":138,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"129\"}},{\"x\":737,\"y\":134,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"130\"}},{\"x\":741,\"y\":131,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"131\"}},{\"x\":743,\"y\":129,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"132\"}},{\"x\":753,\"y\":134,\"z\":804,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"133\"}},{\"x\":755,\"y\":139,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"134\"}},{\"x\":757,\"y\":131,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"135\"}},{\"x\":772,\"y\":140,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"136\"}},{\"x\":773,\"y\":144,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"137\"}},{\"x\":784,\"y\":142,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"138\"}},{\"x\":785,\"y\":141,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"139\"}},{\"x\":793,\"y\":147,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"140\"}},{\"x\":785,\"y\":137,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"141\"}},{\"x\":790,\"y\":133,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"142\"}},{\"x\":806,\"y\":131,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"143\"}},{\"x\":803,\"y\":131,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"144\"}}]"; WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, "crystal_hollows"); - WaypointGroup expectedWaypointGroup = new WaypointGroup("Coleweight", "crystal_hollows", List.of( - new OrderedNamedWaypoint(new BlockPos(821, 137, 809), "1", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(821, 143, 809), "2", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(812, 154, 798), "3", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(817, 159, 803), "4", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(814, 168, 798), "5", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(814, 171, 809), "6", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(810, 177, 821), "7", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(803, 183, 821), "8", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(802, 178, 817), "9", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(803, 175, 811), "10", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(800, 167, 799), "11", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(787, 174, 809), "12", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(783, 177, 820), "13", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(766, 177, 822), "14", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(769, 175, 811), "15", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(775, 170, 810), "16", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(778, 161, 800), "17", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(787, 155, 792), "18", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(778, 153, 801), "19", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(789, 154, 809), "20", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(794, 159, 823), "21", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(804, 163, 816), "22", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(794, 164, 800), "23", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(801, 168, 795), "24", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(806, 161, 783), "25", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(801, 157, 778), "26", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(791, 161, 781), "27", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(796, 164, 776), "28", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(798, 167, 774), "29", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(803, 161, 764), "30", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(810, 159, 762), "31", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(817, 156, 767), "32", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(821, 149, 754), "33", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(814, 139, 742), "34", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(818, 137, 736), "35", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(818, 143, 736), "36", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(802, 140, 739), "37", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(804, 131, 730), "38", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(792, 121, 726), "39", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(788, 127, 727), "40", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(792, 127, 726), "41", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(783, 123, 731), "42", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(786, 122, 717), "43", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(785, 124, 707), "44", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(769, 129, 709), "45", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(764, 131, 716), "46", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(757, 131, 717), "47", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(755, 139, 727), "48", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(753, 134, 723), "49", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(768, 126, 723), "50", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(770, 122, 720), "51", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(777, 116, 720), "52", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(779, 113, 725), "53", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(786, 116, 742), "54", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(783, 123, 752), "55", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(778, 125, 762), "56", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(784, 131, 754), "57", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(789, 135, 760), "58", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(792, 138, 758), "59", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(802, 138, 769), "60", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(807, 142, 780), "61", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(805, 132, 775), "62", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(820, 123, 772), "63", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(813, 131, 766), "64", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(812, 127, 763), "65", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(804, 126, 753), "66", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(810, 125, 750), "67", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(821, 127, 751), "68", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(815, 124, 742), "69", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(815, 120, 732), "70", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(806, 115, 732), "71", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(796, 125, 741), "72", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(798, 119, 757), "73", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(799, 112, 763), "74", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(783, 110, 765), "75", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(804, 116, 777), "76", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(801, 116, 788), "77", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(793, 110, 798), "78", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(795, 107, 800), "79", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(805, 100, 803), "80", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(821, 105, 809), "81", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(818, 96, 816), "82", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(803, 92, 802), "83", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(793, 97, 813), "84", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(791, 94, 809), "85", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(787, 94, 810), "86", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(775, 92, 802), "87", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(771, 91, 799), "88", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(763, 89, 805), "89", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(768, 101, 806), "90", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(785, 105, 808), "91", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(791, 101, 805), "92", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(791, 103, 784), "93", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(771, 102, 778), "94", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(764, 99, 781), "95", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(758, 97, 792), "96", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(762, 93, 783), "97", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(778, 92, 775), "98", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(786, 90, 784), "99", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(790, 88, 792), "100", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(792, 82, 815), "101", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(783, 76, 811), "102", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(795, 69, 821), "103", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(800, 66, 807), "104", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(810, 65, 811), "105", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(817, 75, 813), "106", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(815, 75, 800), "107", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(822, 85, 800), "108", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(822, 85, 785), "109", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(811, 88, 778), "110", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(804, 86, 792), "111", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(792, 78, 790), "112", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(790, 77, 793), "113", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(785, 68, 800), "114", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(773, 75, 797), "115", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(773, 78, 794), "116", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(757, 83, 797), "117", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(742, 84, 791), "118", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(737, 85, 797), "119", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(731, 75, 813), "120", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(731, 81, 816), "121", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(743, 82, 821), "122", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(746, 96, 798), "123", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(742, 110, 788), "124", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(745, 110, 807), "125", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(752, 113, 805), "126", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(742, 123, 801), "127", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(736, 129, 801), "128", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(733, 138, 795), "129", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(737, 134, 792), "130", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(741, 131, 799), "131", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(743, 129, 802), "132", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(753, 134, 804), "133", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(755, 139, 808), "134", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(757, 131, 798), "135", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(772, 140, 803), "136", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(773, 144, 797), "137", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(784, 142, 797), "138", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(785, 141, 795), "139", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(793, 147, 801), "140", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(785, 137, 810), "141", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(790, 133, 800), "142", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(806, 131, 803), "143", new float[]{0, 1, 0}), - new OrderedNamedWaypoint(new BlockPos(803, 131, 809), "144", new float[]{0, 1, 0}) - ), true); - Assertions.assertEquals(expectedWaypointGroup.waypoints().size(), waypointGroup.waypoints().size()); - for (int i = 0; i < waypointGroup.waypoints().size(); i++) { - Assertions.assertEquals(expectedWaypointGroup.waypoints().get(i), waypointGroup.waypoints().get(i)); - } - Assertions.assertEquals(expectedWaypointGroup.name(), waypointGroup.name()); - Assertions.assertEquals(expectedWaypointGroup.island(), waypointGroup.island()); - Assertions.assertEquals(expectedWaypointGroup.ordered(), waypointGroup.ordered()); - Assertions.assertEquals(expectedWaypointGroup, waypointGroup); + Assertions.assertEquals(SAPPHIRE_WAYOINTS, waypointGroup); + } + + @Test + void testFromSkyblocker() { + String waypointGroupsSkyblocker = "[Skyblocker-Waypoint-Data-V1]H4sIAAAAAAAA/92dQWscORCF7/4VZs4hSOqWStpr/sFeQ1iGeFgbJtNm7GDCkv++7ZD1znsTqujjSyCHcTtuv0gqfVUqVX28ub39Z/17e7t72X97XB5Oz0+7P24//vjSf49+PP68HJfzh+XL43I64De9/knv07uLjxk/rk/fPn36/8Fuf3y8368/Kb2vF199ul++Hu/+PJzuDuf14fP56+Hi6ePC7+4lw7snu/zY0/jlu0/7L4f1B+3y7ufXvr9TFj1PW0QXUdG5wLvrfPnRRndFT6qiDUUPHOnJFT2rioahza1vGen6e4i2jCPtr+mmKhrfbWi9S3ZFm6joBOY692mL6K4qGq23wZpezZwreqiK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skdln7oqlFEtAarP6PtaXZTJOM8sUXUYf6MeokzGGdLMZL7XMUSZjG+b81j7M3yIQtmVajzL7H4+ylClMiPVdG4dzHBVLMNseIwZRuUUhiqWVXS1qEajTyhDFcsaTOhBi9r3OoYsluFIb8pFGapYhhmzAwOEkflWxTKU2anyUVC9LqliGXlX+Cn783vFGVHVeMhjFCqLKgvLYhkwd6PqdZFqUSyjgspYfLYHNzNzEsUySjtqG2tni3IZlcPhGrs+ouQkCmaUgEOqo2qzSZTMOt5U6xtVi6KZq9p6tF+LstlqsBw2CzzrrNsKAMP9mJ0QEalsKwDysYjDg3Ut2wqAnCyKKAQ7l2wrALRfGBgPbbhsKwCju5g41gGR6rYCoIARqvaDClm2FQCWzSC/MxxrUTYzvKnWqdlc4H3ItgKg9okb17UomxnfNt7kc8m2AkDVnT75Z7hZtRWAUa9Mih0G61q2FcCM4XDi8MD7UG0FQDac04SD5Ois2gvA5urIDuOFqs0ArNJoUxubILAg2w2AJnnZ1r1Hth3ARNe4xjbZsoBGt803dTfJqg0BiEu5nFsUSFLtCGAzNTfflFKZVVsCEKNdre1otFUhza1Z2FMQX1BtCuAXqIzSKrNqV4CgGmnE5KptAcy8AvnRda6s2heAQod5pg0sYHLVxgBc1o3KP4WyVSmNMsVnWtsBpcm2BqBruTNdUA2YXLY3AI02xVCjDsGyzQHwvC9P5HhGskUpjaumUBQ12sBU2wNwSzaWHbgiF/0Bbi6+abec1/cf7uA3ePtXH5bj4eXw8Pf98+7nk4en4/70+t27z+dvT8/741/3y/G4vDy9/vTvN5/+BQTM0qPSigAA"; + List waypointGroups = Waypoints.fromSkyblocker(waypointGroupsSkyblocker); + List expectedWaypointGroups = List.of(SAPPHIRE_WAYOINTS); + + Assertions.assertEquals(expectedWaypointGroups, waypointGroups); + } + + @Test + void testToSkyblocker() { + String waypointGroupsSkyblocker = Waypoints.toSkyblocker(List.of(SAPPHIRE_WAYOINTS)); + String expectedWaypointGroupsSkyblocker = "[Skyblocker-Waypoint-Data-V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vC9P5HhGskUpjaumUBQ12sBU2wNwSzaWHbgiF/0Bbi6+abec1/cf7uA3ePtXH5bj4eXw8Pf98+7nk4en4/70+t27z+dvT8/741/3y/G4vDy9/vTvN5/+BQTM0qPSigAA"; + + Assertions.assertEquals(expectedWaypointGroupsSkyblocker, waypointGroupsSkyblocker); } } From 228c7acc6f5a710c56ab817c8b7c113166925c7b Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 19:22:03 -0400 Subject: [PATCH 07/18] Fix UI --- .../skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java | 2 +- .../skyblocker/skyblock/waypoint/WaypointsShareScreen.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java index feae3782ff..cdf2e74c81 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java @@ -36,7 +36,7 @@ public AbstractWaypointsScreen(Text title, T parent, Multimap(client, width - 160, 8, 150, height - 8, Arrays.asList(Location.values()), this::islandChanged, Location.from(island))); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index 5b288090c2..a1c45c93b9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -91,7 +91,7 @@ protected void init() { }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSnoopy.tooltip"))).build()); adder.add(ButtonWidget.builder(ScreenTexts.DONE, buttonBack -> close()).build()); gridWidget.refreshPositions(); - SimplePositioningWidget.setPos(gridWidget, 0, this.height - 64, this.width, 64); + SimplePositioningWidget.setPos(gridWidget, 0, this.height - 76, this.width, 64); gridWidget.forEachChild(this::addDrawableChild); } From 7a892db3925158e84d8816bc081bebc0a94af3b3 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 20:07:28 -0400 Subject: [PATCH 08/18] Deprecate OrderedWaypoints and migrate to Waypoints --- .../skyblock/waypoint/OrderedWaypoints.java | 394 ++---------------- .../utils/waypoint/NamedWaypoint.java | 17 +- .../utils/waypoint/OrderedNamedWaypoint.java | 11 +- .../utils/waypoint/WaypointGroup.java | 12 +- 4 files changed, 69 insertions(+), 365 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index 6d87310d11..4af61a34de 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -1,11 +1,9 @@ package de.hysky.skyblocker.skyblock.waypoint; import com.google.common.primitives.Floats; -import com.google.gson.Gson; import com.google.gson.JsonParser; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.logging.LogUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; @@ -13,299 +11,82 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.utils.CodecUtils; -import de.hysky.skyblocker.utils.ColorUtils; import de.hysky.skyblocker.utils.Constants; -import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.command.argumenttypes.blockpos.ClientBlockPosArgumentType; -import de.hysky.skyblocker.utils.command.argumenttypes.blockpos.ClientPosArgument; -import de.hysky.skyblocker.utils.command.argumenttypes.color.ColorArgumentType; -import de.hysky.skyblocker.utils.render.RenderHelper; +import de.hysky.skyblocker.utils.waypoint.OrderedNamedWaypoint; import de.hysky.skyblocker.utils.waypoint.Waypoint; +import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import it.unimi.dsi.fastutil.floats.FloatArrayList; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.command.CommandSource; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import org.slf4j.Logger; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Semaphore; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import static com.mojang.brigadier.arguments.StringArgumentType.getString; -import static com.mojang.brigadier.arguments.StringArgumentType.word; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; +/** + * @deprecated Use {@link Waypoints} instead. + */ +@SuppressWarnings("DeprecatedIsStillUsed") +@Deprecated public class OrderedWaypoints { private static final Logger LOGGER = LogUtils.getLogger(); private static final Codec> SERIALIZATION_CODEC = Codec.unboundedMap(Codec.STRING, OrderedWaypointGroup.CODEC).xmap(Object2ObjectOpenHashMap::new, Object2ObjectOpenHashMap::new); private static final String PREFIX = "[Skyblocker::OrderedWaypoints::v1]"; public static final Path PATH = SkyblockerMod.CONFIG_DIR.resolve("ordered_waypoints.json"); - private static final Map WAYPOINTS = new Object2ObjectOpenHashMap<>(); - private static final Semaphore SEMAPHORE = new Semaphore(1); - private static final Object2IntOpenHashMap INDEX_STORE = new Object2IntOpenHashMap<>(); - public static final int RADIUS = 2; - private static final float[] LIGHT_GRAY = { 192 / 255f, 192 / 255f, 192 / 255f }; - - private static CompletableFuture loaded; - private static boolean showAll; @Init public static void init() { ClientLifecycleEvents.CLIENT_STARTED.register(_client -> load()); - ClientLifecycleEvents.CLIENT_STOPPING.register(_client -> save()); ClientCommandRegistrationCallback.EVENT.register(OrderedWaypoints::registerCommands); - WorldRenderEvents.AFTER_TRANSLUCENT.register(OrderedWaypoints::render); } private static void registerCommands(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) { dispatcher.register(literal(SkyblockerMod.NAMESPACE) .then(literal("waypoints") .then(literal("ordered") - .then(literal("add") - .then(argument("groupName", word()) - .suggests((source, builder) -> CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) - .then(argument("pos", ClientBlockPosArgumentType.blockPos()) - .executes(context -> addWaypoint(context.getSource(), getString(context, "groupName"), context.getArgument("pos", ClientPosArgument.class), Integer.MIN_VALUE, Integer.MIN_VALUE)) - .then(argument("hex", ColorArgumentType.hex()) - .executes(context -> addWaypoint(context.getSource(), getString(context, "groupName"), context.getArgument("pos", ClientPosArgument.class), Integer.MIN_VALUE, ColorArgumentType.getIntFromHex(context, "hex"))))))) - .then(literal("addAt") - .then(argument("groupName", word()) - .suggests((source, builder) -> CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) - .then(argument("index", IntegerArgumentType.integer(0)) - .then(argument("pos", ClientBlockPosArgumentType.blockPos()) - .executes(context -> addWaypoint(context.getSource(), getString(context, "groupName"), context.getArgument("pos", ClientPosArgument.class), IntegerArgumentType.getInteger(context, "index"), Integer.MIN_VALUE)) - .then(argument("hex", ColorArgumentType.hex()) - .executes(context -> addWaypoint(context.getSource(), getString(context, "groupName"), context.getArgument("pos", ClientPosArgument.class), IntegerArgumentType.getInteger(context, "index"), ColorArgumentType.getIntFromHex(context, "hex")))))))) - .then(literal("remove") - .then(argument("groupName", word()) - .suggests((source, builder) -> CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) - .executes(context -> removeWaypointGroup(context.getSource(), getString(context, "groupName"))) - .then(argument("pos", ClientBlockPosArgumentType.blockPos()) - .executes(context -> removeWaypoint(context.getSource(), getString(context, "groupName"), context.getArgument("pos", ClientPosArgument.class), Integer.MIN_VALUE))))) - .then(literal("removeAt") - .then(argument("groupName", word()) - .suggests((source, builder) -> CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) - .then(argument("index", IntegerArgumentType.integer(0)) - .executes(context -> removeWaypoint(context.getSource(), getString(context, "groupName"), null, IntegerArgumentType.getInteger(context, "index")))))) - .then(literal("toggle") - .then(argument("groupName", word()) - .suggests((source, builder) -> CommandSource.suggestMatching(WAYPOINTS.keySet(), builder)) - .executes(context -> toggleGroup(context.getSource(), getString(context, "groupName"))))) - .then(literal("showAll") - .executes(context -> showAll(context.getSource()))) .then(literal("import") - .then(literal("coleWeight") - .then(argument("groupName", word()) - .executes(context -> fromColeWeightFormat(context.getSource(), getString(context, "groupName"))))) .then(literal("skyblocker") - .executes(context -> fromSkyblockerFormat(context.getSource())))) - .then(literal("export") - .executes(context -> export(context.getSource())))))); - } - - private static int addWaypoint(FabricClientCommandSource source, String groupName, ClientPosArgument posArgument, int index, int color) { - BlockPos pos = posArgument.toAbsoluteBlockPos(source); - - SEMAPHORE.acquireUninterruptibly(); - - float[] colorComponents = color != Integer.MIN_VALUE ? ColorUtils.getFloatComponents(color) : new float[0]; - - OrderedWaypointGroup group = WAYPOINTS.computeIfAbsent(groupName, name -> new OrderedWaypointGroup(name, true, new ObjectArrayList<>())); - OrderedWaypoint waypoint = new OrderedWaypoint(pos, colorComponents); - - if (index != Integer.MIN_VALUE) { - int indexToAddAt = Math.clamp(index, 0, group.waypoints().size()); - - group.waypoints().add(indexToAddAt, waypoint); - INDEX_STORE.removeInt(group.name()); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.addAt.success", group.name(), indexToAddAt))); - } else { - group.waypoints().add(waypoint); - INDEX_STORE.removeInt(group.name()); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.add.success", group.name(), pos.toShortString()))); - } - - SEMAPHORE.release(); - - return Command.SINGLE_SUCCESS; - } - - private static int removeWaypointGroup(FabricClientCommandSource source, String groupName) { - if (WAYPOINTS.containsKey(groupName)) { - SEMAPHORE.acquireUninterruptibly(); - WAYPOINTS.remove(groupName); - INDEX_STORE.removeInt(groupName); - SEMAPHORE.release(); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.removeGroup.success", groupName))); - } else { - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.groupNonExistent", groupName))); - } - - return Command.SINGLE_SUCCESS; - } - - private static int removeWaypoint(FabricClientCommandSource source, String groupName, ClientPosArgument posArgument, int index) { - if (WAYPOINTS.containsKey(groupName)) { - SEMAPHORE.acquireUninterruptibly(); - OrderedWaypointGroup group = WAYPOINTS.get(groupName); - - if (posArgument != null) { - BlockPos pos = posArgument.toAbsoluteBlockPos(source); - - group.waypoints().removeIf(waypoint -> waypoint.getPos().equals(pos)); - INDEX_STORE.removeInt(group.name()); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.remove.success", pos.toShortString(), group.name()))); - } - - if (index != Integer.MIN_VALUE) { - int indexToRemove = Math.clamp(index, 0, group.waypoints().size() - 1); - - group.waypoints().remove(indexToRemove); - INDEX_STORE.removeInt(group.name()); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.removeAt.success", indexToRemove, group.name()))); - } - - SEMAPHORE.release(); - } else { - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.groupNonExistent", groupName))); - } - - return Command.SINGLE_SUCCESS; - } - - private static int toggleGroup(FabricClientCommandSource source, String groupName) { - if (WAYPOINTS.containsKey(groupName)) { - SEMAPHORE.acquireUninterruptibly(); - WAYPOINTS.put(groupName, WAYPOINTS.get(groupName).toggle()); - SEMAPHORE.release(); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.toggle.success", groupName))); - } else { - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.groupNonExistent", groupName))); - } - - return Command.SINGLE_SUCCESS; - } - - private static int showAll(FabricClientCommandSource source) { - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.showAll"))); - showAll = !showAll; - - return Command.SINGLE_SUCCESS; - } - - private static void render(WorldRenderContext wrc) { - if ((Utils.isInCrystalHollows() || Utils.isInDwarvenMines()) && loaded.isDone() && SEMAPHORE.tryAcquire()) { - for (OrderedWaypointGroup group : WAYPOINTS.values()) { - if (group.enabled()) { - List waypoints = group.waypoints(); - if (waypoints.isEmpty()) continue; - - if (!showAll) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - int centreIndex = INDEX_STORE.computeIfAbsent(group.name(), name -> 0); - - for (int i = 0; i < waypoints.size(); i++) { - OrderedWaypoint waypoint = waypoints.get(i); - - if (waypoint.getPos().isWithinDistance(player.getPos(), RADIUS)) { - centreIndex = i; - INDEX_STORE.put(group.name(), i); - - break; - } - } - - int previousIndex = (centreIndex - 1 + waypoints.size()) % waypoints.size(); - int currentIndex = (centreIndex + waypoints.size()) % waypoints.size(); - int nextIndex = (centreIndex + 1) % waypoints.size(); - - OrderedWaypoint previous = waypoints.get(previousIndex); - OrderedWaypoint current = waypoints.get(currentIndex); - OrderedWaypoint next = waypoints.get(nextIndex); - - previous.render(wrc, RelativeIndex.PREVIOUS, previousIndex); - current.render(wrc, RelativeIndex.CURRENT, currentIndex); - next.render(wrc, RelativeIndex.NEXT, nextIndex); - - RenderHelper.renderLineFromCursor(wrc, Vec3d.ofCenter(next.getPos().up()), LIGHT_GRAY, 1f, 5f); - } else { - for (int i = 0; i < waypoints.size(); i++) { - //Render them as white by default - waypoints.get(i).render(wrc, RelativeIndex.CURRENT, i); - } - } - } - } - - SEMAPHORE.release(); - } + .executes(context -> fromSkyblockerFormat(context.getSource()))))))); } + /** + * Loads and migrates the ordered waypoints to waypoints. + * @deprecated Use {@link Waypoints} instead. + */ + @Deprecated private static void load() { - loaded = CompletableFuture.runAsync(() -> { - try (BufferedReader reader = Files.newBufferedReader(PATH)) { - WAYPOINTS.putAll(SERIALIZATION_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow()); - } catch (NoSuchFileException ignored) { - } catch (Exception e) { - LOGGER.error("[Skyblocker Ordered Waypoints] Failed to load the waypoints! :(", e); - } - }); - } - - private static void save() { - try (BufferedWriter writer = Files.newBufferedWriter(PATH)) { - SkyblockerMod.GSON.toJson(SERIALIZATION_CODEC.encodeStart(JsonOps.INSTANCE, WAYPOINTS).getOrThrow(), writer); - } catch (Exception e) { - LOGGER.error("[Skyblocker Ordered Waypoints] Failed to save the waypoints! :(", e); - } - } - - private static int export(FabricClientCommandSource source) { - try { - String json = new Gson().toJson(SERIALIZATION_CODEC.encodeStart(JsonOps.INSTANCE, WAYPOINTS).getOrThrow()); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - GZIPOutputStream gzip = new GZIPOutputStream(out); - - gzip.write(json.getBytes()); - gzip.close(); - - String encoded = new String(Base64.getEncoder().encode(out.toByteArray())); - String exportCode = PREFIX + encoded; - - MinecraftClient.getInstance().keyboard.setClipboard(exportCode); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.export.success"))); + try (BufferedReader reader = Files.newBufferedReader(PATH)) { + Map orderedWaypoints = SERIALIZATION_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow(); + migrateOrderedWaypoints(orderedWaypoints); + Files.move(PATH, SkyblockerMod.CONFIG_DIR.resolve("legacy_ordered_waypoints.json")); + LOGGER.info("[Skyblocker Ordered Waypoints] Successfully migrated {} ordered waypoints from {} groups to waypoints!", orderedWaypoints.values().stream().map(OrderedWaypointGroup::waypoints).mapToInt(List::size).sum(), orderedWaypoints.size()); + } catch (NoSuchFileException ignored) { } catch (Exception e) { - LOGGER.error("[Skyblocker Ordered Waypoints] Failed to export waypoints!", e); - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.export.fail"))); + LOGGER.error("[Skyblocker Ordered Waypoints] Failed to load the waypoints! :(", e); } - - return Command.SINGLE_SUCCESS; } - //TODO in future handle for when the group names clash? + /** + * @deprecated Use {@link Waypoints} instead. + */ + @Deprecated private static int fromSkyblockerFormat(FabricClientCommandSource source) { try { String importCode = MinecraftClient.getInstance().keyboard.getClipboard(); @@ -317,10 +98,8 @@ private static int fromSkyblockerFormat(FabricClientCommandSource source) { String json = new String(new GZIPInputStream(new ByteArrayInputStream(decoded)).readAllBytes()); Map importedWaypoints = SERIALIZATION_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(json)).getOrThrow(); - SEMAPHORE.acquireUninterruptibly(); - WAYPOINTS.putAll(importedWaypoints); + migrateOrderedWaypoints(importedWaypoints); source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.import.skyblocker.success"))); - SEMAPHORE.release(); } else { source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.import.skyblocker.unknownFormatHeader"))); } @@ -332,63 +111,32 @@ private static int fromSkyblockerFormat(FabricClientCommandSource source) { return Command.SINGLE_SUCCESS; } - private static int fromColeWeightFormat(FabricClientCommandSource source, String groupName) { - try { - if (WAYPOINTS.containsKey(groupName)) { - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.import.coleWeight.groupAlreadyExists", groupName))); - - return Command.SINGLE_SUCCESS; - } - - String json = MinecraftClient.getInstance().keyboard.getClipboard(); - List coleWeightWaypoints = ColeWeightWaypoint.LIST_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(json)).getOrThrow(); - ObjectArrayList convertedWaypoints = new ObjectArrayList<>(); - - for (ColeWeightWaypoint waypoint : coleWeightWaypoints) { - if (waypoint.x().isPresent() && waypoint.y().isPresent() && waypoint.z().isPresent()) { - //I think Cole Weight ignores the colors and overrides them so we will comment this out - //float[] colorComponents = (waypoint.r().isPresent() && waypoint.g().isPresent() && waypoint.b().isPresent()) ? new float[] { waypoint.r().get() / 255f, waypoint.g().get() / 255f, waypoint.b().get() / 255f } : new float[0]; - - convertedWaypoints.add(new OrderedWaypoint(new BlockPos(waypoint.x().getAsInt(), waypoint.y().getAsInt(), waypoint.z().getAsInt()), new float[0])); - } - } - - SEMAPHORE.acquireUninterruptibly(); - WAYPOINTS.put(groupName, new OrderedWaypointGroup(groupName, true, convertedWaypoints)); - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.import.coleWeight.success"))); - SEMAPHORE.release(); - } catch (Exception e) { - LOGGER.error("[Skyblocker Ordered Waypoints] Failed to import waypoints from the Cole Weight format!", e); - source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.waypoints.ordered.import.coleWeight.fail"))); + /** + * Migrates the given ordered waypoints to waypoints. + */ + private static void migrateOrderedWaypoints(Map orderedWaypoints) { + for (OrderedWaypointGroup legacyGroup : orderedWaypoints.values()) { + WaypointGroup group = new WaypointGroup(legacyGroup.name, "", legacyGroup.waypoints.stream().map(waypoint -> new OrderedNamedWaypoint(waypoint.pos, "", new float[]{0, 1, 0})).collect(Collectors.toList()), true); + Waypoints.waypoints.put(group.island(), group); } - - return Command.SINGLE_SUCCESS; } + @Deprecated private record OrderedWaypointGroup(String name, boolean enabled, ObjectArrayList waypoints) { static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("name").forGetter(OrderedWaypointGroup::name), Codec.BOOL.fieldOf("enabled").forGetter(OrderedWaypointGroup::enabled), - OrderedWaypoint.LIST_CODEC.fieldOf("waypoints").xmap(ObjectArrayList::new, ObjectArrayList::new).forGetter(OrderedWaypointGroup::waypoints)) - .apply(instance, OrderedWaypointGroup::new)); - - OrderedWaypointGroup toggle() { - return new OrderedWaypointGroup(name, !enabled, waypoints); - } + OrderedWaypoint.LIST_CODEC.fieldOf("waypoints").xmap(ObjectArrayList::new, ObjectArrayList::new).forGetter(OrderedWaypointGroup::waypoints) + ).apply(instance, OrderedWaypointGroup::new)); } + @Deprecated private static class OrderedWaypoint extends Waypoint { static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - BlockPos.CODEC.fieldOf("pos").forGetter(OrderedWaypoint::getPos), - Codec.floatRange(0, 1).listOf().xmap(Floats::toArray, FloatArrayList::new).optionalFieldOf("colorComponents", new float[0]).forGetter(inst -> inst.colorComponents.length == 3 ? inst.colorComponents : new float[0])) + BlockPos.CODEC.fieldOf("pos").forGetter(OrderedWaypoint::getPos), + Codec.floatRange(0, 1).listOf().xmap(Floats::toArray, FloatArrayList::new).optionalFieldOf("colorComponents", new float[0]).forGetter(inst -> inst.colorComponents.length == 3 ? inst.colorComponents : new float[0])) .apply(instance, OrderedWaypoint::new)); static final Codec> LIST_CODEC = CODEC.listOf(); - static final float[] RED = { 1f, 0f, 0f }; - static final float[] WHITE = { 1f, 1f, 1f }; - static final float[] GREEN = { 0f, 1f, 0f }; - - private RelativeIndex relativeIndex; - private int waypointIndex; OrderedWaypoint(BlockPos pos, float[] colorComponents) { super(pos, () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents); @@ -397,63 +145,5 @@ private static class OrderedWaypoint extends Waypoint { private BlockPos getPos() { return this.pos; } - - @Override - public float[] getRenderColorComponents() { - if (this.colorComponents.length != 3) { - return switch (this.relativeIndex) { - case NONE -> this.colorComponents; - case PREVIOUS -> RED; - case CURRENT -> WHITE; - case NEXT -> GREEN; - }; - } - - return this.colorComponents; - } - - private void render(WorldRenderContext context, RelativeIndex relativeIndex, int waypointIndex) { - this.relativeIndex = relativeIndex; - this.waypointIndex = waypointIndex; - - render(context); - } - - @Override - public void render(WorldRenderContext context) { - super.render(context); - RenderHelper.renderText(context, Text.of(String.valueOf(waypointIndex)), Vec3d.ofCenter(pos.up(2)), true); - } - } - - public record ColeWeightWaypoint(OptionalInt x, OptionalInt y, OptionalInt z, OptionalInt r, OptionalInt g, OptionalInt b, Optional options) { - static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("x")).forGetter(ColeWeightWaypoint::x), - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("y")).forGetter(ColeWeightWaypoint::y), - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("z")).forGetter(ColeWeightWaypoint::z), - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("r")).forGetter(ColeWeightWaypoint::r), - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("g")).forGetter(ColeWeightWaypoint::g), - CodecUtils.optionalInt(Codec.INT.optionalFieldOf("b")).forGetter(ColeWeightWaypoint::b), - Options.CODEC.optionalFieldOf("options").forGetter(ColeWeightWaypoint::options)) - .apply(instance, ColeWeightWaypoint::new)); - static final Codec> LIST_CODEC = CODEC.listOf(); - - //Even though we don't import the name this is still here incase that eventually changes - public record Options(Optional name) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.STRING.optionalFieldOf("name").forGetter(Options::name)) - .apply(instance, Options::new)); - } - } - - public enum RelativeIndex { - NONE, - PREVIOUS, - CURRENT, - NEXT; - - public boolean shouldRender() { - return this != NONE; - } } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index 5f5d46a820..ec2dd05b6a 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -6,7 +6,6 @@ import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; import de.hysky.skyblocker.utils.CodecUtils; import de.hysky.skyblocker.utils.ColorUtils; import de.hysky.skyblocker.utils.render.RenderHelper; @@ -17,7 +16,9 @@ import net.minecraft.util.math.ColorHelper; import net.minecraft.util.math.Vec3d; -import java.util.*; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalDouble; import java.util.function.Supplier; public class NamedWaypoint extends Waypoint { @@ -46,7 +47,7 @@ public class NamedWaypoint extends Waypoint { CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("r")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[0])), CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("g")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[1])), CodecUtils.optionalDouble(Codec.DOUBLE.optionalFieldOf("b")).forGetter(waypoint -> OptionalDouble.of(waypoint.colorComponents[2])), - OrderedWaypoints.ColeWeightWaypoint.Options.CODEC.optionalFieldOf("options").forGetter(waypoint -> Optional.of(new OrderedWaypoints.ColeWeightWaypoint.Options(Optional.of(waypoint.name.getString())))) + ColeweightOptions.CODEC.optionalFieldOf("options").forGetter(waypoint -> Optional.of(new ColeweightOptions(Optional.of(waypoint.name.getString())))) ).apply(instance, NamedWaypoint::fromColeweight)); public final Text name; public final Vec3d centerPos; @@ -90,8 +91,8 @@ public static NamedWaypoint fromSkytils(int x, int y, int z, String name, int co } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - public static NamedWaypoint fromColeweight(int x, int y, int z, OptionalDouble r, OptionalDouble g, OptionalDouble b, Optional options) { - return new NamedWaypoint(new BlockPos(x, y, z), options.flatMap(OrderedWaypoints.ColeWeightWaypoint.Options::name).orElse("New Waypoint"), new float[]{(float) r.orElse(0), (float) g.orElse(1), (float) b.orElse(0)}, DEFAULT_HIGHLIGHT_ALPHA, true); + public static NamedWaypoint fromColeweight(int x, int y, int z, OptionalDouble r, OptionalDouble g, OptionalDouble b, Optional options) { + return new NamedWaypoint(new BlockPos(x, y, z), options.flatMap(ColeweightOptions::name).orElse("New Waypoint"), new float[]{(float) r.orElse(0), (float) g.orElse(1), (float) b.orElse(0)}, DEFAULT_HIGHLIGHT_ALPHA, true); } /** @@ -151,4 +152,10 @@ public int hashCode() { public boolean equals(Object obj) { return this == obj || super.equals(obj) && obj instanceof NamedWaypoint waypoint && name.equals(waypoint.name); } + + private record ColeweightOptions(Optional name) { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.STRING.optionalFieldOf("name").forGetter(ColeweightOptions::name) + ).apply(instance, ColeweightOptions::new)); + } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java index 9fa86f44ce..0f3ecf156e 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java @@ -1,7 +1,6 @@ package de.hysky.skyblocker.utils.waypoint; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; import de.hysky.skyblocker.utils.render.RenderHelper; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; @@ -16,7 +15,7 @@ public class OrderedNamedWaypoint extends NamedWaypoint { private static final float[] GREEN_COLOR_COMPONENTS = {0f, 1f, 0f}; int index; - OrderedWaypoints.RelativeIndex relativeIndex; + RelativeIndex relativeIndex; public OrderedNamedWaypoint(NamedWaypoint namedWaypoint) { this(namedWaypoint.pos, namedWaypoint.name, namedWaypoint.typeSupplier, namedWaypoint.colorComponents, namedWaypoint.alpha, namedWaypoint.isEnabled()); @@ -82,4 +81,12 @@ public void render(WorldRenderContext context) { RenderHelper.renderText(context, Text.of(String.valueOf(index)), centerPos.add(0, 1, 0), 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } } + + public enum RelativeIndex { + NONE, PREVIOUS, CURRENT, NEXT; + + public boolean shouldRender() { + return this != NONE; + } + } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java index 039b7ff473..5be87b4950 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java @@ -2,7 +2,6 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints; import de.hysky.skyblocker.utils.InstancedUtils; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; @@ -26,6 +25,7 @@ public class WaypointGroup { NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointGroup::waypoints) ).apply(instance, WaypointGroup::new)); public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointGroup("Coleweight", "", coleWeightWaypoints, true), WaypointGroup::waypoints); + public static final int WAYPOINT_ACTIVATION_RADIUS = 2; private final String name; private final String island; @@ -109,7 +109,7 @@ public void render(WorldRenderContext context) { if (ordered) { for (int i = 0; i < waypoints.size(); i++) { NamedWaypoint waypoint = waypoints.get(i); - if (waypoint.pos.isWithinDistance(MinecraftClient.getInstance().player.getPos(), OrderedWaypoints.RADIUS)) { + if (waypoint.pos.isWithinDistance(MinecraftClient.getInstance().player.getPos(), WAYPOINT_ACTIVATION_RADIUS)) { currentIndex = i; } } @@ -121,13 +121,13 @@ public void render(WorldRenderContext context) { if (waypoint instanceof OrderedNamedWaypoint orderedNamedWaypoint) { orderedNamedWaypoint.index = i; if (i == previousIndex) { - orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.PREVIOUS; + orderedNamedWaypoint.relativeIndex = OrderedNamedWaypoint.RelativeIndex.PREVIOUS; } else if (i == nextIndex) { - orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.NEXT; + orderedNamedWaypoint.relativeIndex = OrderedNamedWaypoint.RelativeIndex.NEXT; } else if (i == currentIndex) { - orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.CURRENT; + orderedNamedWaypoint.relativeIndex = OrderedNamedWaypoint.RelativeIndex.CURRENT; } else { - orderedNamedWaypoint.relativeIndex = OrderedWaypoints.RelativeIndex.NONE; + orderedNamedWaypoint.relativeIndex = OrderedNamedWaypoint.RelativeIndex.NONE; } } } From 081ebd91815d3f69f6dcb98c5af4f2697b1db689 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 31 Aug 2024 20:14:38 -0400 Subject: [PATCH 09/18] Start indices at 1 --- .../hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java index 0f3ecf156e..5ceeeb9e29 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java @@ -78,7 +78,7 @@ public float[] getRenderColorComponents() { public void render(WorldRenderContext context) { super.render(context); if (shouldRenderName()) { - RenderHelper.renderText(context, Text.of(String.valueOf(index)), centerPos.add(0, 1, 0), 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + RenderHelper.renderText(context, Text.of(String.valueOf(index + 1)), centerPos.add(0, 1, 0), 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } } From fb246851eac9254a7a685a3a8fece3dfb234d0a6 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:43:21 -0400 Subject: [PATCH 10/18] Remove unused translations --- .../resources/assets/skyblocker/lang/en_us.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 31e8093fdb..3d97e1458c 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -1115,23 +1115,9 @@ "skyblocker.crimson.kuudra.lowArrowPoison": "Low on Arrow Poison!", "skyblocker.crimson.kuudra.danger": "DANGER!", - "skyblocker.waypoints.ordered.groupNonExistent": "§cThe waypoint group %s doesn't exist.", - "skyblocker.waypoints.ordered.add.invalidHexColor": "§cInvalid HEX color code!", - "skyblocker.waypoints.ordered.addAt.success": "Added a waypoint in group %s at index %d.", - "skyblocker.waypoints.ordered.add.success": "Added a waypoint in group %s at %s.", - "skyblocker.waypoints.ordered.removeGroup.success": "Successfully removed the waypoint group %s.", - "skyblocker.waypoints.ordered.remove.success": "Successfully removed the waypoint at %s from group %s.", - "skyblocker.waypoints.ordered.removeAt.success": "Successfully removed the waypoint at index %d from group %s.", - "skyblocker.waypoints.ordered.toggle.success": "Toggled the waypoint group %s.", - "skyblocker.waypoints.ordered.showAll": "Toggled showing all waypoints from enabled groups.", - "skyblocker.waypoints.ordered.export.success": "Successfully copied your waypoints to your clipboard!", - "skyblocker.waypoints.ordered.export.fail": "§cFailed to export your waypoints, check the latest.log for more information.", "skyblocker.waypoints.ordered.import.skyblocker.success": "Successfully imported waypoints from the Skyblocker Ordered Waypoints format!", "skyblocker.waypoints.ordered.import.skyblocker.unknownFormatHeader": "§cThis import code doesn't look like its in the Skyblocker Ordered Waypoints format, double-check your clipboard to see if everything is correct.", "skyblocker.waypoints.ordered.import.skyblocker.fail": "§cFailed to import waypoints from the Skyblocker Ordered Waypoints format. Make sure to have the waypoint data copied to your clipboard!", - "skyblocker.waypoints.ordered.import.coleWeight.groupAlreadyExists": "§cThere is already an ordered waypoints group under the name \"%s\", please choose another name to import your waypoints under.", - "skyblocker.waypoints.ordered.import.coleWeight.success": "Successfully imported waypoints from the Cole Weight format.", - "skyblocker.waypoints.ordered.import.coleWeight.fail": "§cFailed to import waypoints from the Cole Weight format. Make sure to have the waypoint data copied to your clipboard!", "skyblocker.waypoints.type.WAYPOINT": "Waypoint", "skyblocker.waypoints.type.OUTLINED_WAYPOINT": "Outlined Waypoint", From 7e41b35c2f233939c9236ffb74b7015d3a538a4e Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:53:34 -0400 Subject: [PATCH 11/18] Add Javadocs --- .../skyblocker/utils/waypoint/Waypoint.java | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java index 36776ee055..453ed1b225 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -12,18 +12,32 @@ import java.util.Objects; import java.util.function.Supplier; +/** + * Represents a waypoint with a position, type, color, alpha, line width, through walls, and enabled state. + *

+ * Extend this class and override at least the withers to create custom waypoint types and behavior. + */ public class Waypoint implements Renderable { protected static final float DEFAULT_HIGHLIGHT_ALPHA = 0.5f; protected static final float DEFAULT_LINE_WIDTH = 5f; public final BlockPos pos; final Box box; final Supplier typeSupplier; + /** + * The color components of the waypoint. + *

+ * For custom color behavior, override {@link #getRenderColorComponents()}. + * This field must contain valid color components of the waypoint + * even if this is not being used for rendering (i.e. {@link #getRenderColorComponents()} is overridden) + * since this field is used for serialization. + */ public final float[] colorComponents; public final float alpha; public final float lineWidth; public final boolean throughWalls; private boolean enabled; + // region Constructors public Waypoint(BlockPos pos, Type type, float[] colorComponents) { this(pos, type, colorComponents, DEFAULT_HIGHLIGHT_ALPHA); } @@ -58,37 +72,77 @@ public Waypoint(BlockPos pos, Supplier typeSupplier, float[] colorComponen this.throughWalls = throughWalls; this.enabled = enabled; } + // endregion + // region Withers + /** + * Subclasses should override this method to return a new instance of the subclass with the specified x pos. + */ public Waypoint withX(int x) { return new Waypoint(new BlockPos(x, pos.getY(), pos.getZ()), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } + /** + * Subclasses should override this method to return a new instance of the subclass with the specified y pos. + */ public Waypoint withY(int y) { return new Waypoint(pos.withY(y), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } + /** + * Subclasses should override this method to return a new instance of the subclass with the specified z pos. + */ public Waypoint withZ(int z) { return new Waypoint(new BlockPos(pos.getX(), pos.getY(), z), typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } + /** + * Subclasses should override this method to return a new instance of the subclass with the specified color components and alpha. + */ public Waypoint withColor(float[] colorComponents, float alpha) { return new Waypoint(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, enabled); } + // endregion + // region Getters and Setters + /** + * Whether the waypoint should be rendered. + *

+ * Override this method for custom behavior. + */ public boolean shouldRender() { return enabled; } + /** + * Sets the waypoint as found and enabled as false. + *

+ * Override this method for custom behavior. + */ public void setFound() { this.enabled = false; } + /** + * Sets the waypoint as missing and enabled as true. + *

+ * Override this method for custom behavior. + */ public void setMissing() { this.enabled = true; } + /** + * Toggles the enabled state of the waypoint. + *

+ * Override this method for custom behavior. + */ public void toggle() { - this.enabled = !this.enabled; + if (enabled) { + setFound(); + } else { + setMissing(); + } } public final boolean isEnabled() { @@ -98,11 +152,24 @@ public final boolean isEnabled() { public final void setEnabled(boolean enabled) { this.enabled = enabled; } + // endregion + /** + * Returns the render time color components of the waypoint. + *

+ * Override this method for custom behavior. + */ public float[] getRenderColorComponents() { return colorComponents; } + /** + * Renders the waypoint. + *

+ * Does not check if the waypoint {@link #shouldRender() should be rendered}. + *

+ * Override this method for custom behavior. + */ @Override public void render(WorldRenderContext context) { switch (typeSupplier.get()) { From c2edd5af05f374c55c248a48ca751b1554b3202f Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:06:35 -0400 Subject: [PATCH 12/18] Update waypoint text size --- .../java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java | 2 +- .../hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index ec2dd05b6a..c16de59080 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -138,7 +138,7 @@ protected boolean shouldRenderName() { public void render(WorldRenderContext context) { super.render(context); if (shouldRenderName()) { - float scale = (float) (context.camera().getPos().distanceTo(centerPos) / 10); + float scale = Math.max((float) context.camera().getPos().distanceTo(centerPos) / 10, 1); RenderHelper.renderText(context, name, centerPos.add(0, 1, 0), scale, true); } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java index 5ceeeb9e29..647b15da4d 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/OrderedNamedWaypoint.java @@ -78,7 +78,8 @@ public float[] getRenderColorComponents() { public void render(WorldRenderContext context) { super.render(context); if (shouldRenderName()) { - RenderHelper.renderText(context, Text.of(String.valueOf(index + 1)), centerPos.add(0, 1, 0), 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + float scale = Math.max((float) context.camera().getPos().distanceTo(centerPos) / 10, 1); + RenderHelper.renderText(context, Text.of(String.valueOf(index + 1)), centerPos.add(0, 1, 0), scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); } } From 8434daabc653288c8e454d4f05541f92e32010f9 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:43:12 -0400 Subject: [PATCH 13/18] Refactor mining waypoints --- .../config/categories/MiningCategory.java | 16 -------- .../config/configs/MiningConfig.java | 2 + .../dungeon/secrets/SecretWaypoint.java | 16 ++------ .../skyblock/dwarven/CrystalsHud.java | 12 +++--- .../dwarven/CrystalsLocationsManager.java | 6 +-- .../skyblock/dwarven/MiningLocationLabel.java | 39 ++++++++----------- .../skyblocker/skyblock/rift/EnigmaSouls.java | 17 ++++++-- .../skyblock/waypoint/FairySouls.java | 22 ++++++++--- .../skyblocker/skyblock/waypoint/Relics.java | 13 ++++++- .../waypoint/DistancedNamedWaypoint.java | 34 ++++++++++++++++ .../utils/waypoint/NamedWaypoint.java | 6 ++- .../skyblocker/utils/waypoint/Waypoint.java | 5 ++- 12 files changed, 113 insertions(+), 75 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/utils/waypoint/DistancedNamedWaypoint.java diff --git a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java index 74be78cbb6..364e9b0765 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -181,14 +181,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.mining.crystalsWaypoints.enabled = newValue) .controller(ConfigUtils::createBooleanController) .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.mining.crystalsWaypoints.textScale")) - .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.crystalsWaypoints.textScale.@Tooltip"))) - .binding(defaults.mining.crystalsWaypoints.textScale, - () -> config.mining.crystalsWaypoints.textScale, - newValue -> config.mining.crystalsWaypoints.textScale = newValue) - .controller(FloatFieldControllerBuilder::create) - .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.mining.crystalsWaypoints.findInChat")) .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.crystalsWaypoints.findInChat.@Tooltip"))) @@ -224,14 +216,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.mining.commissionWaypoints.mode = newValue) .controller(ConfigUtils::createEnumCyclingListController) .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.textScale")) - .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.textScale.@Tooltip"))) - .binding(defaults.mining.commissionWaypoints.textScale, - () -> config.mining.commissionWaypoints.textScale, - newValue -> config.mining.commissionWaypoints.textScale = newValue) - .controller(FloatFieldControllerBuilder::create) - .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.mining.commissionWaypoints.useColor")) .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.commissionWaypoints.useColor.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java index 2ef5a4dc89..d2b3beb582 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/MiningConfig.java @@ -102,6 +102,7 @@ public static class CrystalsWaypoints { @SerialEntry public boolean enabled = true; + @Deprecated @SerialEntry public float textScale = 1; @@ -116,6 +117,7 @@ public static class CommissionWaypoints { @SerialEntry public CommissionWaypointMode mode = CommissionWaypointMode.BOTH; + @Deprecated @SerialEntry public float textScale = 1; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java index 3779a66e78..df3d9bf929 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java @@ -7,19 +7,15 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.DungeonsConfig; -import de.hysky.skyblocker.utils.render.RenderHelper; -import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; +import de.hysky.skyblocker.utils.waypoint.DistancedNamedWaypoint; import de.hysky.skyblocker.utils.waypoint.Waypoint; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.minecraft.client.MinecraftClient; import net.minecraft.command.argument.EnumArgumentType; import net.minecraft.entity.Entity; import net.minecraft.text.Text; import net.minecraft.text.TextCodecs; -import net.minecraft.util.Formatting; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,7 +25,7 @@ import java.util.function.Supplier; import java.util.function.ToDoubleFunction; -public class SecretWaypoint extends NamedWaypoint { +public class SecretWaypoint extends DistancedNamedWaypoint { private static final Logger LOGGER = LoggerFactory.getLogger(SecretWaypoint.class); public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.INT.fieldOf("secretIndex").forGetter(secretWaypoint -> secretWaypoint.secretIndex), @@ -94,7 +90,7 @@ public boolean equals(Object obj) { @Override protected boolean shouldRenderName() { - return CONFIG.get().showSecretText; + return super.shouldRenderName() && CONFIG.get().showSecretText; } /** @@ -104,12 +100,6 @@ protected boolean shouldRenderName() { public void render(WorldRenderContext context) { //TODO In the future, shrink the box for wither essence and items so its more realistic super.render(context); - - if (CONFIG.get().showSecretText) { - Vec3d posUp = centerPos.add(0, 1, 0); - double distance = context.camera().getPos().distanceTo(centerPos); - RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); - } } @NotNull diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index 80a3f23243..8689df834e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -74,19 +74,17 @@ private static void render(DrawContext context, int hudX, int hudY) { //if enabled add waypoint locations to map if (SkyblockerConfigManager.get().mining.crystalsHud.showLocations) { - Map ActiveWaypoints = CrystalsLocationsManager.activeWaypoints; - - for (MiningLocationLabel waypoint : ActiveWaypoints.values()) { - int waypointColor = waypoint.category().getColor(); - Vector2ic renderPos = transformLocation(waypoint.centerPos().getX(), waypoint.centerPos().getZ()); + for (MiningLocationLabel waypoint : CrystalsLocationsManager.activeWaypoints.values()) { + MiningLocationLabel.Category category = waypoint.category(); + Vector2ic renderPos = transformLocation(waypoint.centerPos.getX(), waypoint.centerPos.getZ()); int locationSize = SkyblockerConfigManager.get().mining.crystalsHud.locationSize; - if (SMALL_LOCATIONS.contains(waypoint.category().getName())) {//if small location half the location size + if (SMALL_LOCATIONS.contains(category.getName())) {//if small location half the location size locationSize /= 2; } //fill square of size locationSize around the coordinates of the location - context.fill(renderPos.x() - locationSize / 2, renderPos.y() - locationSize / 2, renderPos.x() + locationSize / 2, renderPos.y() + locationSize / 2, waypointColor); + context.fill(renderPos.x() - locationSize / 2, renderPos.y() - locationSize / 2, renderPos.x() + locationSize / 2, renderPos.y() + locationSize / 2, category.getColor()); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index 48dfdd34cf..a97e6051ba 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -294,8 +294,8 @@ public static int addWaypointFromCommand(FabricClientCommandSource source, Strin public static int shareWaypoint(String place) { if (activeWaypoints.containsKey(place)) { - Vec3d pos = activeWaypoints.get(place).centerPos(); - MessageScheduler.INSTANCE.sendMessageAfterCooldown(Constants.PREFIX.get().getString() + " " + place + ": " + (int) pos.getX() + ", " + (int) pos.getY() + ", " + (int) pos.getZ()); + BlockPos pos = activeWaypoints.get(place).pos; + MessageScheduler.INSTANCE.sendMessageAfterCooldown(Constants.PREFIX.get().getString() + " " + place + ": " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ()); } else { //send fail message if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { @@ -349,7 +349,7 @@ private static void removeUnknownNear(BlockPos location) { String name = MiningLocationLabel.CrystalHollowsLocationsCategory.UNKNOWN.getName(); MiningLocationLabel unknownWaypoint = activeWaypoints.getOrDefault(name, null); if (unknownWaypoint != null) { - double distance = unknownWaypoint.centerPos().distanceTo(location.toCenterPos()); + double distance = unknownWaypoint.centerPos.distanceTo(location.toCenterPos()); if (distance < REMOVE_UNKNOWN_DISTANCE) { activeWaypoints.remove(name); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java index 9aabd11734..632ea3fcfe 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java @@ -1,49 +1,42 @@ package de.hysky.skyblocker.skyblock.dwarven; +import com.mojang.serialization.Codec; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.render.RenderHelper; -import de.hysky.skyblocker.utils.render.Renderable; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.minecraft.client.MinecraftClient; +import de.hysky.skyblocker.utils.waypoint.DistancedNamedWaypoint; import net.minecraft.text.Text; import net.minecraft.util.DyeColor; -import net.minecraft.util.Formatting; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import java.awt.*; -import com.mojang.serialization.Codec; +public class MiningLocationLabel extends DistancedNamedWaypoint { + private final Category category; -// TODO: Clean up into the waypoint system with a new `DistancedWaypoint` that extends `NamedWaypoint` for this and secret waypoints. -public record MiningLocationLabel(Category category, Vec3d centerPos) implements Renderable { public MiningLocationLabel(Category category, BlockPos pos) { - this(category, pos.toCenterPos()); + // Set enabled to false in order to prevent the waypoint from being rendered, but the name text and distance will still be rendered. + super(pos, getName(category), new float[]{0, 0, 0}, false); + this.category = category; } - private Text getName() { + private static Text getName(Category category) { if (SkyblockerConfigManager.get().mining.commissionWaypoints.useColor) { return Text.literal(category.getName()).withColor(category.getColor()); } return Text.literal(category.getName()); } + public Category category() { + return category; + } + /** - * Renders the name and distance to the label scaled so can be seen at a distance - * - * @param context render context + * Override the {@link DistancedNamedWaypoint#shouldRenderName()} method to always return true, + * as the name should always be rendered, even though this waypoint is always disabled. */ @Override - public void render(WorldRenderContext context) { - Vec3d posUp = centerPos.add(0, 1, 0); - double distance = context.camera().getPos().distanceTo(centerPos); - //set scale config based on if in crystals or not - float textScale = Utils.isInCrystalHollows() ? SkyblockerConfigManager.get().mining.crystalsWaypoints.textScale : SkyblockerConfigManager.get().mining.commissionWaypoints.textScale; - float scale = (float) (textScale * (distance / 10)); - RenderHelper.renderText(context, getName(), posUp, scale, true); - RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + protected boolean shouldRenderName() { + return true; } public interface Category { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java b/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java index 8e3d1a91d3..e7d07f343e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java @@ -61,7 +61,7 @@ static void load(MinecraftClient client) { for (int i = 0; i < waypoints.size(); i++) { JsonObject waypoint = waypoints.get(i).getAsJsonObject(); BlockPos pos = new BlockPos(waypoint.get("x").getAsInt(), waypoint.get("y").getAsInt(), waypoint.get("z").getAsInt()); - SOUL_WAYPOINTS.put(pos, new ProfileAwareWaypoint(pos, TYPE_SUPPLIER, GREEN, RED)); + SOUL_WAYPOINTS.put(pos, new EnigmaSoul(pos, TYPE_SUPPLIER, GREEN, RED)); } } catch (IOException e) { @@ -114,9 +114,7 @@ static void render(WorldRenderContext context) { if (Utils.isInTheRift() && config.enigmaSoulWaypoints && soulsLoaded.isDone()) { for (Waypoint soul : SOUL_WAYPOINTS.values()) { - if (soul.shouldRender()) { - soul.render(context); - } else if (config.highlightFoundEnigmaSouls) { + if (soul.shouldRender() || config.highlightFoundEnigmaSouls) { soul.render(context); } } @@ -161,4 +159,15 @@ private static void markClosestSoulAsFound() { .filter(soul -> soul.pos.getSquaredDistance(player.getPos()) <= 16) .ifPresent(Waypoint::setFound); } + + private static class EnigmaSoul extends ProfileAwareWaypoint { + public EnigmaSoul(BlockPos pos, Supplier typeSupplier, float[] missingColor, float[] foundColor) { + super(pos, typeSupplier, missingColor, foundColor); + } + + @Override + public boolean shouldRender() { + return super.shouldRender() || SkyblockerConfigManager.get().otherLocations.rift.highlightFoundEnigmaSouls; + } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java index c5b48b93bc..c3a321064f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java @@ -9,11 +9,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.HelperConfig; -import de.hysky.skyblocker.utils.ColorUtils; -import de.hysky.skyblocker.utils.Constants; -import de.hysky.skyblocker.utils.NEURepoManager; -import de.hysky.skyblocker.utils.PosUtils; -import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.*; import de.hysky.skyblocker.utils.waypoint.ProfileAwareWaypoint; import de.hysky.skyblocker.utils.waypoint.Waypoint; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -76,7 +72,7 @@ public static void init() { private static void loadFairySouls() { fairySoulsLoaded = NEURepoManager.runAsyncAfterLoad(() -> { maxSouls = NEURepoManager.NEU_REPO.getConstants().getFairySouls().getMaxSouls(); - NEURepoManager.NEU_REPO.getConstants().getFairySouls().getSoulLocations().forEach((location, fairiesForLocation) -> fairySouls.put(location, fairiesForLocation.stream().map(coordinate -> new BlockPos(coordinate.getX(), coordinate.getY(), coordinate.getZ())).collect(Collectors.toUnmodifiableMap(pos -> pos, pos -> new ProfileAwareWaypoint(pos, TYPE_SUPPLIER, ColorUtils.getFloatComponents(DyeColor.GREEN), ColorUtils.getFloatComponents(DyeColor.RED)))))); + NEURepoManager.NEU_REPO.getConstants().getFairySouls().getSoulLocations().forEach((location, fairiesForLocation) -> fairySouls.put(location, fairiesForLocation.stream().map(coordinate -> new BlockPos(coordinate.getX(), coordinate.getY(), coordinate.getZ())).collect(Collectors.toUnmodifiableMap(pos -> pos, pos -> new FairySoul(pos, TYPE_SUPPLIER, ColorUtils.getFloatComponents(DyeColor.GREEN), ColorUtils.getFloatComponents(DyeColor.RED)))))); LOGGER.debug("[Skyblocker] Loaded {} fairy souls across {} locations", fairySouls.values().stream().mapToInt(Map::size).sum(), fairySouls.size()); try (BufferedReader reader = Files.newBufferedReader(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json"))) { @@ -200,4 +196,18 @@ public static void markAllFairiesOnCurrentIslandMissing() { fairiesForLocation.values().forEach(ProfileAwareWaypoint::setMissing); } } + + private static class FairySoul extends ProfileAwareWaypoint { + public FairySoul(BlockPos pos, Supplier typeSupplier, float[] missingColor, float[] foundColor) { + super(pos, typeSupplier, missingColor, foundColor); + } + + /** + * Less strict than the check {@link FairySouls#render(WorldRenderContext)} since this only needs to ensure found fairy souls are rendered if the config is enabled. + */ + @Override + public boolean shouldRender() { + return super.shouldRender() || SkyblockerConfigManager.get().helpers.fairySouls.highlightFoundSouls; + } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java index 520ddfd4e6..b86c70979b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Relics.java @@ -69,7 +69,7 @@ private static void loadRelics(MinecraftClient client) { for (JsonElement locationJson : json.getValue().getAsJsonArray().asList()) { JsonObject posData = locationJson.getAsJsonObject(); BlockPos pos = new BlockPos(posData.get("x").getAsInt(), posData.get("y").getAsInt(), posData.get("z").getAsInt()); - relics.put(pos, new ProfileAwareWaypoint(pos, TYPE_SUPPLIER, ColorUtils.getFloatComponents(DyeColor.YELLOW), ColorUtils.getFloatComponents(DyeColor.BROWN))); + relics.put(pos, new Relic(pos, TYPE_SUPPLIER, ColorUtils.getFloatComponents(DyeColor.YELLOW), ColorUtils.getFloatComponents(DyeColor.BROWN))); } } } @@ -164,4 +164,15 @@ private static void markClosestRelicFound() { .filter(relic -> relic.pos.getSquaredDistance(player.getPos()) <= 16) .ifPresent(Waypoint::setFound); } + + private static class Relic extends ProfileAwareWaypoint { + public Relic(BlockPos pos, Supplier typeSupplier, float[] missingColor, float[] foundColor) { + super(pos, typeSupplier, missingColor, foundColor); + } + + @Override + public boolean shouldRender() { + return super.shouldRender() || SkyblockerConfigManager.get().otherLocations.spidersDen.relics.highlightFoundRelics; + } + } } diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/DistancedNamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/DistancedNamedWaypoint.java new file mode 100644 index 0000000000..0cb60178ca --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/DistancedNamedWaypoint.java @@ -0,0 +1,34 @@ +package de.hysky.skyblocker.utils.waypoint; + +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; + +import java.util.function.Supplier; + +public class DistancedNamedWaypoint extends NamedWaypoint { + public DistancedNamedWaypoint(BlockPos pos, Text name, float[] colorComponents, boolean enabled) { + super(pos, name, colorComponents, enabled); + } + + public DistancedNamedWaypoint(BlockPos pos, Text name, Supplier typeSupplier, float[] colorComponents) { + super(pos, name, typeSupplier, colorComponents); + } + + public boolean shouldRenderDistance() { + return shouldRenderName(); + } + + @Override + public void render(WorldRenderContext context) { + super.render(context); + if (shouldRenderDistance()) { + double distance = context.camera().getPos().distanceTo(centerPos); + float scale = Math.max((float) distance / 10, 1); + RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), centerPos.add(0, 1, 0), scale, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java index c16de59080..2b9cb26ede 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/NamedWaypoint.java @@ -68,6 +68,10 @@ public NamedWaypoint(BlockPos pos, String name, float[] colorComponents, float a this(pos, Text.of(name), colorComponents, alpha, enabled); } + public NamedWaypoint(BlockPos pos, Text name, float[] colorComponents, boolean enabled) { + this(pos, name, () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, enabled); + } + public NamedWaypoint(BlockPos pos, Text name, float[] colorComponents, float alpha, boolean enabled) { this(pos, name, () -> SkyblockerConfigManager.get().uiAndVisuals.waypoints.waypointType, colorComponents, alpha, enabled); } @@ -131,7 +135,7 @@ public NamedWaypoint withName(String name) { } protected boolean shouldRenderName() { - return true; + return shouldRender(); } @Override diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java index 453ed1b225..e2e246a31a 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -108,6 +108,8 @@ public Waypoint withColor(float[] colorComponents, float alpha) { /** * Whether the waypoint should be rendered. *

+ * Checked in {@link #render(WorldRenderContext)} before rendering. + *

* Override this method for custom behavior. */ public boolean shouldRender() { @@ -166,12 +168,13 @@ public float[] getRenderColorComponents() { /** * Renders the waypoint. *

- * Does not check if the waypoint {@link #shouldRender() should be rendered}. + * Checks if the waypoint {@link #shouldRender() should be rendered}. *

* Override this method for custom behavior. */ @Override public void render(WorldRenderContext context) { + if (!shouldRender()) return; switch (typeSupplier.get()) { case WAYPOINT -> RenderHelper.renderFilledWithBeaconBeam(context, pos, getRenderColorComponents(), alpha, throughWalls); case OUTLINED_WAYPOINT -> { From 5345d14a28cbf1751bbcdeb5b9c7b7541226189d Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 8 Oct 2024 01:40:09 -0400 Subject: [PATCH 14/18] Migrate from String to Location --- .../waypoint/AbstractWaypointsScreen.java | 16 +++++----- .../skyblock/waypoint/OrderedWaypoints.java | 3 +- .../skyblock/waypoint/Waypoints.java | 20 ++++++------- .../waypoint/WaypointsListWidget.java | 5 ++-- .../waypoint/WaypointsShareScreen.java | 3 +- .../de/hysky/skyblocker/utils/Location.java | 12 +++++++- .../utils/waypoint/WaypointGroup.java | 19 ++++++------ .../utils/waypoint/WaypointGroupTest.java | 5 ++-- .../utils/waypoint/WaypointsTest.java | 29 ++++++++++--------- 9 files changed, 64 insertions(+), 48 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java index cdf2e74c81..e41c1eb820 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/AbstractWaypointsScreen.java @@ -13,20 +13,20 @@ public abstract class AbstractWaypointsScreen extends Screen { protected final T parent; - protected final Multimap waypoints; - protected String island; + protected final Multimap waypoints; + protected Location island; protected WaypointsListWidget waypointsListWidget; protected DropdownWidget islandWidget; public AbstractWaypointsScreen(Text title, T parent) { - this(title, parent, MultimapBuilder.hashKeys().arrayListValues().build()); + this(title, parent, MultimapBuilder.enumKeys(Location.class).arrayListValues().build()); } - public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints) { - this(title, parent, waypoints, Utils.getLocationRaw()); + public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints) { + this(title, parent, waypoints, Utils.getLocation()); } - public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints, String island) { + public AbstractWaypointsScreen(Text title, T parent, Multimap waypoints, Location island) { super(title); this.parent = parent; this.waypoints = waypoints; @@ -37,7 +37,7 @@ public AbstractWaypointsScreen(Text title, T parent, Multimap(client, width - 160, 8, 150, height - 8, Arrays.asList(Location.values()), this::islandChanged, Location.from(island))); + islandWidget = addDrawableChild(new DropdownWidget<>(client, width - 160, 8, 150, height - 8, Arrays.asList(Location.values()), this::islandChanged, island)); } @Override @@ -59,7 +59,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmou } protected void islandChanged(Location location) { - island = location.id(); + island = location; waypointsListWidget.setIsland(island); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java index 4af61a34de..9d253567f9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/OrderedWaypoints.java @@ -12,6 +12,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Constants; +import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.waypoint.OrderedNamedWaypoint; import de.hysky.skyblocker.utils.waypoint.Waypoint; import de.hysky.skyblocker.utils.waypoint.WaypointGroup; @@ -116,7 +117,7 @@ private static int fromSkyblockerFormat(FabricClientCommandSource source) { */ private static void migrateOrderedWaypoints(Map orderedWaypoints) { for (OrderedWaypointGroup legacyGroup : orderedWaypoints.values()) { - WaypointGroup group = new WaypointGroup(legacyGroup.name, "", legacyGroup.waypoints.stream().map(waypoint -> new OrderedNamedWaypoint(waypoint.pos, "", new float[]{0, 1, 0})).collect(Collectors.toList()), true); + WaypointGroup group = new WaypointGroup(legacyGroup.name, Location.UNKNOWN, legacyGroup.waypoints.stream().map(waypoint -> new OrderedNamedWaypoint(waypoint.pos, "", new float[]{0, 1, 0})).collect(Collectors.toList()), true); Waypoints.waypoints.put(group.island(), group); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java index 3e873d215f..1117fb0bf6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java @@ -45,7 +45,7 @@ public class Waypoints { protected static final SystemToast.Type WAYPOINTS_TOAST_TYPE = new SystemToast.Type(); private static final Path waypointsFile = FabricLoader.getInstance().getConfigDir().resolve(SkyblockerMod.NAMESPACE).resolve("waypoints.json"); - protected static final Multimap waypoints = MultimapBuilder.hashKeys().arrayListValues().build(); + protected static final Multimap waypoints = MultimapBuilder.enumKeys(Location.class).arrayListValues().build(); @Init public static void init() { @@ -97,7 +97,7 @@ public static String toSkyblocker(List waypointGroups) { return PREFIX + new String(Base64.getEncoder().encode(output.toByteArray())); } - public static List fromSkytils(String waypointsString, String defaultIsland) { + public static List fromSkytils(String waypointsString, Location defaultIsland) { try { if (waypointsString.startsWith("(V")) { int version = Integer.parseInt(waypointsString.substring(25, waypointsString.indexOf(')'))); @@ -118,7 +118,7 @@ public static List fromSkytils(String waypointsString, String def return Collections.emptyList(); } - public static List fromSkytilsJson(String waypointGroupsString, String defaultIsland) { + public static List fromSkytilsJson(String waypointGroupsString, Location defaultIsland) { JsonArray waypointGroupsJson; try { waypointGroupsJson = SkyblockerMod.GSON.fromJson(waypointGroupsString, JsonObject.class).getAsJsonArray("categories"); @@ -126,13 +126,13 @@ public static List fromSkytilsJson(String waypointGroupsString, S // Handle the case where there is only a single json list of waypoints and no group data. JsonObject waypointGroupJson = new JsonObject(); waypointGroupJson.addProperty("name", "New Group"); - waypointGroupJson.addProperty("island", defaultIsland); + waypointGroupJson.addProperty("island", defaultIsland.id()); waypointGroupJson.add("waypoints", SkyblockerMod.GSON.fromJson(waypointGroupsString, JsonArray.class)); waypointGroupsJson = new JsonArray(); waypointGroupsJson.add(waypointGroupJson); } List waypointGroups = SKYTILS_CODEC.parse(JsonOps.INSTANCE, waypointGroupsJson).resultOrPartial(LOGGER::error).orElseThrow(); - return waypointGroups.stream().map(waypointGroup -> Location.from(waypointGroup.island()) == Location.UNKNOWN ? waypointGroup.withIsland(defaultIsland) : waypointGroup).toList(); + return waypointGroups.stream().map(waypointGroup -> waypointGroup.island() == Location.UNKNOWN ? waypointGroup.withIsland(defaultIsland) : waypointGroup).toList(); } public static String toSkytilsBase64(List waypointGroups) { @@ -145,23 +145,23 @@ public static String toSkytilsJson(List waypointGroups) { return SkyblockerMod.GSON_COMPACT.toJson(waypointGroupsJson); } - public static WaypointGroup fromColeweightJson(String waypointsJson, String defaultIsland) { + public static WaypointGroup fromColeweightJson(String waypointsJson, Location defaultIsland) { return WaypointGroup.COLEWEIGHT_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseString(waypointsJson)).resultOrPartial(LOGGER::error).orElseThrow().withIsland(defaultIsland); } - public static Multimap waypointsDeepCopy() { - return waypoints.values().stream().map(WaypointGroup::deepCopy).collect(Multimaps.toMultimap(WaypointGroup::island, Function.identity(), () -> MultimapBuilder.hashKeys().arrayListValues().build())); + public static Multimap waypointsDeepCopy() { + return waypoints.values().stream().map(WaypointGroup::deepCopy).collect(Multimaps.toMultimap(WaypointGroup::island, Function.identity(), () -> MultimapBuilder.enumKeys(Location.class).arrayListValues().build())); } public static void render(WorldRenderContext context) { if (SkyblockerConfigManager.get().uiAndVisuals.waypoints.enableWaypoints) { - for (WaypointGroup group : waypoints.get(Utils.getLocationRaw())) { + for (WaypointGroup group : waypoints.get(Utils.getLocation())) { if (group != null) { group.render(context); } } if (Utils.getLocationRaw().isEmpty()) return; - for (WaypointGroup group : waypoints.get("")) { + for (WaypointGroup group : waypoints.get(Location.UNKNOWN)) { if (group != null) { group.render(context); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java index 06e4d00b69..a7fc30c226 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.waypoint; import de.hysky.skyblocker.mixins.accessors.CheckboxWidgetAccessor; +import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; @@ -21,7 +22,7 @@ public class WaypointsListWidget extends ElementListWidget { private final AbstractWaypointsScreen screen; - private String island; + private Location island; private List waypoints; public WaypointsListWidget(MinecraftClient client, AbstractWaypointsScreen screen, int width, int height, int y, int itemHeight) { @@ -49,7 +50,7 @@ Optional getGroup() { return Optional.empty(); } - void setIsland(String island) { + void setIsland(Location island) { this.island = island; waypoints = (List) screen.waypoints.get(island); updateEntries(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index a1c45c93b9..fed71464ec 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.waypoint; import com.google.common.collect.Multimap; +import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; import de.hysky.skyblocker.utils.waypoint.WaypointGroup; import net.minecraft.client.gui.DrawContext; @@ -19,7 +20,7 @@ public class WaypointsShareScreen extends AbstractWaypointsScreen { private final Set selectedWaypoints = new HashSet<>(); - protected WaypointsShareScreen(WaypointsScreen parent, Multimap waypoints) { + protected WaypointsShareScreen(WaypointsScreen parent, Multimap waypoints) { super(Text.translatable("skyblocker.waypoints.shareWaypoints"), parent, waypoints, parent.island); } diff --git a/src/main/java/de/hysky/skyblocker/utils/Location.java b/src/main/java/de/hysky/skyblocker/utils/Location.java index 1f6c93a0ca..225df3086d 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Location.java +++ b/src/main/java/de/hysky/skyblocker/utils/Location.java @@ -1,11 +1,14 @@ package de.hysky.skyblocker.utils; +import com.mojang.serialization.Codec; +import net.minecraft.util.StringIdentifiable; + import java.util.Arrays; /** * All Skyblock locations */ -public enum Location { +public enum Location implements StringIdentifiable { /** * mode: dynamic */ @@ -95,6 +98,8 @@ public enum Location { */ UNKNOWN("unknown"); + public static final Codec CODEC = StringIdentifiable.createCodec(Location::values); + /** * location id from Hypixel API */ @@ -114,6 +119,11 @@ public String id() { return this.id; } + @Override + public String asString() { + return id(); + } + /** * @param id location id from Hypixel API * @return location object diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java index 5be87b4950..fe8c99cc70 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/WaypointGroup.java @@ -3,6 +3,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.hysky.skyblocker.utils.InstancedUtils; +import de.hysky.skyblocker.utils.Location; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.MinecraftClient; import net.minecraft.util.math.BlockPos; @@ -14,34 +15,34 @@ public class WaypointGroup { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("name").forGetter(WaypointGroup::name), - Codec.STRING.fieldOf("island").forGetter(WaypointGroup::island), + Codec.STRING.fieldOf("island").xmap(Location::from, Location::id).forGetter(WaypointGroup::island), NamedWaypoint.CODEC.listOf().fieldOf("waypoints").forGetter(WaypointGroup::waypoints), Codec.BOOL.lenientOptionalFieldOf("ordered", false).forGetter(WaypointGroup::ordered), Codec.INT.lenientOptionalFieldOf("currentIndex", 0).forGetter(group -> group.currentIndex) ).apply(instance, WaypointGroup::new)); public static final Codec SKYTILS_CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("name").forGetter(WaypointGroup::name), - Codec.STRING.fieldOf("island").forGetter(WaypointGroup::island), + Codec.STRING.fieldOf("island").xmap(Location::from, Location::id).forGetter(WaypointGroup::island), NamedWaypoint.SKYTILS_CODEC.listOf().fieldOf("waypoints").forGetter(WaypointGroup::waypoints) ).apply(instance, WaypointGroup::new)); - public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointGroup("Coleweight", "", coleWeightWaypoints, true), WaypointGroup::waypoints); + public static final Codec COLEWEIGHT_CODEC = NamedWaypoint.COLEWEIGHT_CODEC.listOf().xmap(coleWeightWaypoints -> new WaypointGroup("Coleweight", Location.UNKNOWN, coleWeightWaypoints, true), WaypointGroup::waypoints); public static final int WAYPOINT_ACTIVATION_RADIUS = 2; private final String name; - private final String island; + private final Location island; private final List waypoints; private final boolean ordered; protected int currentIndex; - public WaypointGroup(String name, String island, List waypoints) { + public WaypointGroup(String name, Location island, List waypoints) { this(name, island, waypoints, false); } - public WaypointGroup(String name, String island, List waypoints, boolean ordered) { + public WaypointGroup(String name, Location island, List waypoints, boolean ordered) { this(name, island, waypoints, ordered, 0); } - public WaypointGroup(String name, String island, List waypoints, boolean ordered, int currentIndex) { + public WaypointGroup(String name, Location island, List waypoints, boolean ordered, int currentIndex) { this.name = name; this.island = island; // Set ordered first since convertWaypoint depends on it @@ -54,7 +55,7 @@ public String name() { return name; } - public String island() { + public Location island() { return island; } @@ -70,7 +71,7 @@ public WaypointGroup withName(String name) { return new WaypointGroup(name, island, waypoints, ordered, currentIndex); } - public WaypointGroup withIsland(String island) { + public WaypointGroup withIsland(Location island) { return new WaypointGroup(name, island, waypoints, ordered, currentIndex); } diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java index fca053d675..e998048e56 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointGroupTest.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.utils.Location; import net.minecraft.Bootstrap; import net.minecraft.SharedConstants; import net.minecraft.util.math.BlockPos; @@ -21,7 +22,7 @@ static void beforeAll() { @Test void testCodecEncode() { - WaypointGroup group = new WaypointGroup("group", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); + WaypointGroup group = new WaypointGroup("group", Location.HUB, List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); JsonElement groupJson = WaypointGroup.CODEC.encodeStart(JsonOps.INSTANCE, group).result().orElseThrow(); JsonElement expectedJson = SkyblockerMod.GSON.fromJson("{\"name\":\"group\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}", JsonElement.class); @@ -32,7 +33,7 @@ void testCodecEncode() { void testCodecDecode() { String groupJson = "{\"name\":\"group\",\"island\":\"hub\",\"waypoints\":[{\"colorComponents\":[0.0,0.5,1.0],\"alpha\":0.5,\"shouldRender\":false,\"pos\":[0,0,0],\"name\":\"waypoint\"},{\"colorComponents\":[0.0,0.0,0.0],\"alpha\":0.5,\"shouldRender\":true,\"pos\":[-1,0,1],\"name\":\"waypoint\"}]}"; WaypointGroup group = WaypointGroup.CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(groupJson, JsonElement.class)).result().orElseThrow(); - WaypointGroup expectedGroup = new WaypointGroup("group", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); + WaypointGroup expectedGroup = new WaypointGroup("group", Location.HUB, List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "waypoint", new float[]{0f, 0f, 0f}, true))); Assertions.assertEquals(expectedGroup, group); } diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java index 40cfd73593..5e0a1dc67f 100644 --- a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointsTest.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.utils.waypoint; import de.hysky.skyblocker.skyblock.waypoint.Waypoints; +import de.hysky.skyblocker.utils.Location; import net.minecraft.Bootstrap; import net.minecraft.SharedConstants; import net.minecraft.util.math.BlockPos; @@ -11,7 +12,7 @@ import java.util.List; public class WaypointsTest { - private static final WaypointGroup SAPPHIRE_WAYOINTS = new WaypointGroup("Coleweight", "crystal_hollows", List.of( + private static final WaypointGroup SAPPHIRE_WAYOINTS = new WaypointGroup("Coleweight", Location.CRYSTAL_HOLLOWS, List.of( new OrderedNamedWaypoint(new BlockPos(821, 137, 809), "1", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(821, 143, 809), "2", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(812, 154, 798), "3", new float[]{0, 1, 0}), @@ -167,15 +168,15 @@ public static void setup() { @Test void testFromSkytilsBase64() { String waypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsIngiOjAsInkiOjAsInoiOjAsImVuYWJsZWQiOmZhbHNlLCJjb2xvciI6LTg3MjM4MjIwOSwiYWRkZWRBdCI6MX0seyJuYW1lIjoxLCJ4IjotMSwieSI6MCwieiI6MSwiZW5hYmxlZCI6dHJ1ZSwiY29sb3IiOjAsImFkZGVkQXQiOjF9XSwiaXNsYW5kIjoiaHViIn1dfQ=="; - List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, ""); - List expectedWaypointGroups = List.of(new WaypointGroup("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5019608f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); + List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, Location.UNKNOWN); + List expectedWaypointGroups = List.of(new WaypointGroup("category", Location.HUB, List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5019608f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); Assertions.assertEquals(expectedWaypointGroups, waypointGroups); } @Test void testToSkytilsBase64() { - List waypointGroups = List.of(new WaypointGroup("category", "hub", List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); + List waypointGroups = List.of(new WaypointGroup("category", Location.HUB, List.of(new NamedWaypoint(BlockPos.ORIGIN, "waypoint", new float[]{0f, 0.5f, 1f}, 0.8f, false), new NamedWaypoint(new BlockPos(-1, 0, 1), "1", new float[]{0f, 0f, 0f}, true)))); String waypointGroupsSkytilsBase64 = Waypoints.toSkytilsBase64(waypointGroups); String expectedWaypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjpbeyJuYW1lIjoiY2F0ZWdvcnkiLCJpc2xhbmQiOiJodWIiLCJ3YXlwb2ludHMiOlt7Im5hbWUiOiJ3YXlwb2ludCIsImNvbG9yIjotODcyMzgyNDY1LCJlbmFibGVkIjpmYWxzZSwieCI6MCwieSI6MCwieiI6MH0seyJuYW1lIjoiMSIsImNvbG9yIjoyMTMwNzA2NDMyLCJlbmFibGVkIjp0cnVlLCJ4IjotMSwieSI6MCwieiI6MX1dfV19"; @@ -186,8 +187,8 @@ void testToSkytilsBase64() { @Test void testFromSkytilsBase64GlacialCaveWaypoints() { String waypointGroupsSkytilsBase64 = "eyJjYXRlZ29yaWVzIjogW3sibmFtZSI6ICJGcm96ZW4gVHJlYXN1cmUgTG9jYXRpb25zIiwid2F5cG9pbnRzIjogW3sibmFtZSI6ICIyNCIsIngiOiA2NCwieSI6IDc4LCJ6IjogMjgsImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODU0MDY3MTksImFkZGVkQXQiOiAxNjY5OTk5NzUwNjc3fSx7Im5hbWUiOiAiOSIsIngiOiA0NSwieSI6IDc5LCJ6IjogNDksImVuYWJsZWQiOiB0cnVlLCJjb2xvciI6IDEwODUyNzM1OTksImFkZGVkQXQiOiAxNjY5OTk5NTEwMTA3fSx7Im5hbWUiOiAiMjAiLCJ4IjogNjAsInkiOiA3NiwieiI6IDUxLCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiA5NTMzNTE5MzUsImFkZGVkQXQiOiAxNjY5OTk5NzQ5MzI3fSx7Im5hbWUiOiAiMjMiLCJ4IjogNjMsInkiOiA3NiwieiI6IDk1LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDIwNDYxMDUyLCJhZGRlZEF0IjogMTY2OTk5OTc1MDQ3N30seyJuYW1lIjogI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jb2xvciI6IDEwNTI3NzAyOTgsImFkZGVkQXQiOiAxNjcwMDAwMDIyMTc0fSx7Im5hbWUiOiAiMzciLCJ4IjogOTEsInkiOiA3NiwieiI6IDM4LCJlbmFibGVkIjogdHJ1ZSwiY29sb3IiOiAxMDUxMTMxMzkxLCJhZGRlZEF0IjogMTY3MDAwMDIyNjQyM30seyJuYW1lIjogIjQ1IiwieCI6IDk4LCJ5IjogNzgsInoiOiA3NSwiZW5hYmxlZCI6IHRydWUsImNvbG9yIjogMTIwMjg0NzczNywiYWRkZWRBdCI6IDE2NzAwMDAyMjgwNzN9XSwiaXNsYW5kIjogIndpbnRlciJ9XX0="; - List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, ""); - List expectedWaypointGroups = List.of(new WaypointGroup("Frozen Treasure Locations", "winter", List.of( + List waypointGroups = Waypoints.fromSkytils(waypointGroupsSkytilsBase64, Location.UNKNOWN); + List expectedWaypointGroups = List.of(new WaypointGroup("Frozen Treasure Locations", Location.WINTER_ISLAND, List.of( new NamedWaypoint(new BlockPos(64, 78, 28), "24", new float[]{177 / 255f, 253 / 255f, 255 / 255f}, 64 / 255f, true), new NamedWaypoint(new BlockPos(45, 79, 49), "9", new float[]{175 / 255f, 245 / 255f, 255 / 255f}, 64 / 255f, true), new NamedWaypoint(new BlockPos(60, 76, 51), "20", new float[]{210 / 255f, 254 / 255f, 255 / 255f}, 56 / 255f, true), @@ -244,8 +245,8 @@ void testFromSkytilsBase64GlacialCaveWaypoints() { @Test void testFromSkytilsBase64CrystalHollowsWaypoints() { String waypointsSkytilsBase64 = "W3sibmFtZSI6IlNob3V0b3V0IFRlYmV5IGFuZCB0cmV2YW55YSIsIngiOjUxMCwieSI6NTMsInoiOjM5MywiaXNsYW5kIjoiY3J5c3RhbF9ob2xsb3dzIiwiZW5hYmxlZCI6dHJ1ZSwiY29sb3IiOi02NTUzNn0seyJuYW1lIjoiMDciLCJ4Ijo0NzksInkiOjM5LCJ6Ijo0MDgsIml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= List.of(new WaypointGroup("New Group", "crystal_hollows", List.of( + List waypointGroups = Waypoints.fromSkytils(waypointsSkytilsBase64, Location.CRYSTAL_HOLLOWS); + List expectedWaypointGroups = List.of(new WaypointGroup("New Group", Location.CRYSTAL_HOLLOWS, List.of( new NamedWaypoint(new BlockPos(510, 53, 393), "Shoutout Tebey and trevanya", new float[]{1, 0, 0}, 1, true), new NamedWaypoint(new BlockPos(479, 39, 408), "07", new float[]{1, 0, 0}, 1, true), new NamedWaypoint(new BlockPos(495, 34, 418), "11", new float[]{1, 0, 0}, 1, true), @@ -280,12 +281,12 @@ void testFromSkytilsBase64CrystalHollowsWaypoints() { @Test void testFromSkytilsV1Gzip() { String waypointsSkytilsV1Gzip = "(V1):H4sIAAAAAAAC/51STWuEMBD9KyHntJjJl7u3UugfsIdC2UOq6SKk0cZIaxf/e+OC4moL4i2TmXnvzby54FwHc658aRp8RK8X7PSHiS+ctXVtO5Tpd4OyugoNJvhLd3VVurAs/Wy1NzH/HaM7yinBXXwpSfDP8HNICDZOv1lTxDD41hCsi8IUDyHGVCp+4JLGPi57MoMN2gf07EvtznaCl+kCnQJsgGeRgfM5/BJ4UHkFVhNwukm34sD6E8FlY7UbKnHpmqBdHtvmhE+tsejRWLtpqaM8BPfJKDGlS4mMrSXmla38NSu4lDDYsVItEg5ws46XyT8QKxa5j4UBCEhuPN1xKluYIBVUsZt55oujbJxJTObu3BxPmAL51yGhkU2tL4nuJBMCgP57XKf+FzPhnyPAAwAA"; - List waypointGroups = Waypoints.fromSkytils(waypointsSkytilsV1Gzip, "default_island"); - List expectedWaypointGroups = List.of(new WaypointGroup("Supply Safe Spots", "default_island", List.of( + List waypointGroups = Waypoints.fromSkytils(waypointsSkytilsV1Gzip, Location.UNKNOWN); + List expectedWaypointGroups = List.of(new WaypointGroup("Supply Safe Spots", Location.UNKNOWN, List.of( new NamedWaypoint(new BlockPos(-141, 76, -90), "Square", new float[]{0, 1, 0}, 128 / 255f, true), new NamedWaypoint(new BlockPos(-68, 76, -122), "Start Triangle", new float[]{0, 1, 0}, 128 / 255f, true), new NamedWaypoint(new BlockPos(-90, 77, -128), "Triangle", new float[]{0, 1, 0}, 128 / 255f, true) - )), new WaypointGroup("Fuel Cell Safe Spots", "default_island", List.of( + )), new WaypointGroup("Fuel Cell Safe Spots", Location.UNKNOWN, List.of( new NamedWaypoint(new BlockPos(-81, 77, -133), "Triangle 2.0", new float[]{20 / 255f, 0, 1}, 1, true), new NamedWaypoint(new BlockPos(-125, 77, -136), "X", new float[]{20 / 255f, 0, 1}, 1, true), new NamedWaypoint(new BlockPos(-141, 76, -90), "Square", new float[]{20 / 255f, 0, 1}, 1, true), @@ -299,8 +300,8 @@ void testFromSkytilsV1Gzip() { @Test void testFromColeweightJson() { String coleweightJson = "[{\"x\":64,\"y\":78,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":45,\"y\":79,\"z\":49,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":60,\"y\":76,\"z\":51,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":63,\"y\":76,\"z\":95,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":63,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":94,\"y\":77,\"z\":42,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":91,\"y\":77,\"z\":27,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":50,\"y\":80,\"z\":88,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":50,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":58,\"y\":79,\"z\":89,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":78,\"y\":74,\"z\":99,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":46,\"y\":80,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":97,\"y\":81,\"z\":77,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":55,\"y\":79,\"z\":34,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":39,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":95,\"y\":76,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":97,\"y\":75,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":45,\"y\":79,\"z\":70,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":75,\"y\":82,\"z\":20,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":36,\"y\":80,\"z\":80,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":43,\"y\":77,\"z\":50,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":43,\"y\":79,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":35,\"y\":8,\"z\":71,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":89,\"y\":77,\"z\":84,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":73,\"y\":76,\"z\":31,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":47,\"y\":77,\"z\":65,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":52,\"y\":75,\"z\":45,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":82,\"y\":78,\"z\":26,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":61,\"y\":78,\"z\":92,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":73,\"y\":79,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":103,\"y\":74,\"z\":98,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":104,\"y\":78,\"z\":68,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":42,\"y\":77,\"z\":58,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":41,\"y\":79,\"z\":81,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":90,\"y\":77,\"z\":46,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":32,\"y\":80,\"z\":74,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":78,\"y\":77,\"z\":40,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":76,\"y\":76,\"z\":55,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":66,\"y\":81,\"z\":28,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":90,\"y\":77,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":55,\"y\":80,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":92,\"y\":74,\"z\":108,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":50,\"y\":76,\"z\":52,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":98,\"y\":77,\"z\":76,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":79,\"y\":80,\"z\":73,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":91,\"y\":76,\"z\":38,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":98,\"y\":78,\"z\":75,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}}]"; - WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, "winter"); - WaypointGroup expectedWaypointGroup = new WaypointGroup("Coleweight", "winter", List.of( + WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, Location.WINTER_ISLAND); + WaypointGroup expectedWaypointGroup = new WaypointGroup("Coleweight", Location.WINTER_ISLAND, List.of( new OrderedNamedWaypoint(new BlockPos(64, 78, 28), "24", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(45, 79, 49), "9", new float[]{0, 1, 0}), new OrderedNamedWaypoint(new BlockPos(60, 76, 51), "20", new float[]{0, 1, 0}), @@ -356,7 +357,7 @@ void testFromColeweightJson() { @Test void testFromColeweightJsonSapphire() { String coleweightJson = "[{\"x\":821,\"y\":137,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"1\"}},{\"x\":821,\"y\":143,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"2\"}},{\"x\":812,\"y\":154,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"3\"}},{\"x\":817,\"y\":159,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"4\"}},{\"x\":814,\"y\":168,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"5\"}},{\"x\":814,\"y\":171,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"6\"}},{\"x\":810,\"y\":177,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"7\"}},{\"x\":803,\"y\":183,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"8\"}},{\"x\":802,\"y\":178,\"z\":817,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"9\"}},{\"x\":803,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"10\"}},{\"x\":800,\"y\":167,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"11\"}},{\"x\":787,\"y\":174,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"12\"}},{\"x\":783,\"y\":177,\"z\":820,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"13\"}},{\"x\":766,\"y\":177,\"z\":822,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"14\"}},{\"x\":769,\"y\":175,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"15\"}},{\"x\":775,\"y\":170,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"16\"}},{\"x\":778,\"y\":161,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"17\"}},{\"x\":787,\"y\":155,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"18\"}},{\"x\":778,\"y\":153,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"19\"}},{\"x\":789,\"y\":154,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"20\"}},{\"x\":794,\"y\":159,\"z\":823,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"21\"}},{\"x\":804,\"y\":163,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"22\"}},{\"x\":794,\"y\":164,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"23\"}},{\"x\":801,\"y\":168,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"24\"}},{\"x\":806,\"y\":161,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"25\"}},{\"x\":801,\"y\":157,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"26\"}},{\"x\":791,\"y\":161,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"27\"}},{\"x\":796,\"y\":164,\"z\":776,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"28\"}},{\"x\":798,\"y\":167,\"z\":774,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"29\"}},{\"x\":803,\"y\":161,\"z\":764,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"30\"}},{\"x\":810,\"y\":159,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"31\"}},{\"x\":817,\"y\":156,\"z\":767,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"32\"}},{\"x\":821,\"y\":149,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"33\"}},{\"x\":814,\"y\":139,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"34\"}},{\"x\":818,\"y\":137,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"35\"}},{\"x\":818,\"y\":143,\"z\":736,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"36\"}},{\"x\":802,\"y\":140,\"z\":739,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"37\"}},{\"x\":804,\"y\":131,\"z\":730,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"38\"}},{\"x\":792,\"y\":121,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"39\"}},{\"x\":788,\"y\":127,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"40\"}},{\"x\":792,\"y\":127,\"z\":726,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"41\"}},{\"x\":783,\"y\":123,\"z\":731,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"42\"}},{\"x\":786,\"y\":122,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"43\"}},{\"x\":785,\"y\":124,\"z\":707,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"44\"}},{\"x\":769,\"y\":129,\"z\":709,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"45\"}},{\"x\":764,\"y\":131,\"z\":716,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"46\"}},{\"x\":757,\"y\":131,\"z\":717,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"47\"}},{\"x\":755,\"y\":139,\"z\":727,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"48\"}},{\"x\":753,\"y\":134,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"49\"}},{\"x\":768,\"y\":126,\"z\":723,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"50\"}},{\"x\":770,\"y\":122,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"51\"}},{\"x\":777,\"y\":116,\"z\":720,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"52\"}},{\"x\":779,\"y\":113,\"z\":725,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"53\"}},{\"x\":786,\"y\":116,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"54\"}},{\"x\":783,\"y\":123,\"z\":752,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"55\"}},{\"x\":778,\"y\":125,\"z\":762,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"56\"}},{\"x\":784,\"y\":131,\"z\":754,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"57\"}},{\"x\":789,\"y\":135,\"z\":760,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"58\"}},{\"x\":792,\"y\":138,\"z\":758,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"59\"}},{\"x\":802,\"y\":138,\"z\":769,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"60\"}},{\"x\":807,\"y\":142,\"z\":780,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"61\"}},{\"x\":805,\"y\":132,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"62\"}},{\"x\":820,\"y\":123,\"z\":772,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"63\"}},{\"x\":813,\"y\":131,\"z\":766,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"64\"}},{\"x\":812,\"y\":127,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"65\"}},{\"x\":804,\"y\":126,\"z\":753,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"66\"}},{\"x\":810,\"y\":125,\"z\":750,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"67\"}},{\"x\":821,\"y\":127,\"z\":751,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"68\"}},{\"x\":815,\"y\":124,\"z\":742,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"69\"}},{\"x\":815,\"y\":120,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"70\"}},{\"x\":806,\"y\":115,\"z\":732,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"71\"}},{\"x\":796,\"y\":125,\"z\":741,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"72\"}},{\"x\":798,\"y\":119,\"z\":757,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"73\"}},{\"x\":799,\"y\":112,\"z\":763,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"74\"}},{\"x\":783,\"y\":110,\"z\":765,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"75\"}},{\"x\":804,\"y\":116,\"z\":777,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"76\"}},{\"x\":801,\"y\":116,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"77\"}},{\"x\":793,\"y\":110,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"78\"}},{\"x\":795,\"y\":107,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"79\"}},{\"x\":805,\"y\":100,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"80\"}},{\"x\":821,\"y\":105,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"81\"}},{\"x\":818,\"y\":96,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"82\"}},{\"x\":803,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"83\"}},{\"x\":793,\"y\":97,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"84\"}},{\"x\":791,\"y\":94,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"85\"}},{\"x\":787,\"y\":94,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"86\"}},{\"x\":775,\"y\":92,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"87\"}},{\"x\":771,\"y\":91,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"88\"}},{\"x\":763,\"y\":89,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"89\"}},{\"x\":768,\"y\":101,\"z\":806,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"90\"}},{\"x\":785,\"y\":105,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"91\"}},{\"x\":791,\"y\":101,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"92\"}},{\"x\":791,\"y\":103,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"93\"}},{\"x\":771,\"y\":102,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"94\"}},{\"x\":764,\"y\":99,\"z\":781,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"95\"}},{\"x\":758,\"y\":97,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"96\"}},{\"x\":762,\"y\":93,\"z\":783,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"97\"}},{\"x\":778,\"y\":92,\"z\":775,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"98\"}},{\"x\":786,\"y\":90,\"z\":784,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"99\"}},{\"x\":790,\"y\":88,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"100\"}},{\"x\":792,\"y\":82,\"z\":815,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"101\"}},{\"x\":783,\"y\":76,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"102\"}},{\"x\":795,\"y\":69,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"103\"}},{\"x\":800,\"y\":66,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"104\"}},{\"x\":810,\"y\":65,\"z\":811,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"105\"}},{\"x\":817,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"106\"}},{\"x\":815,\"y\":75,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"107\"}},{\"x\":822,\"y\":85,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"108\"}},{\"x\":822,\"y\":85,\"z\":785,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"109\"}},{\"x\":811,\"y\":88,\"z\":778,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"110\"}},{\"x\":804,\"y\":86,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"111\"}},{\"x\":792,\"y\":78,\"z\":790,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"112\"}},{\"x\":790,\"y\":77,\"z\":793,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"113\"}},{\"x\":785,\"y\":68,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"114\"}},{\"x\":773,\"y\":75,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"115\"}},{\"x\":773,\"y\":78,\"z\":794,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"116\"}},{\"x\":757,\"y\":83,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"117\"}},{\"x\":742,\"y\":84,\"z\":791,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"118\"}},{\"x\":737,\"y\":85,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"119\"}},{\"x\":731,\"y\":75,\"z\":813,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"120\"}},{\"x\":731,\"y\":81,\"z\":816,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"121\"}},{\"x\":743,\"y\":82,\"z\":821,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"122\"}},{\"x\":746,\"y\":96,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"123\"}},{\"x\":742,\"y\":110,\"z\":788,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"124\"}},{\"x\":745,\"y\":110,\"z\":807,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"125\"}},{\"x\":752,\"y\":113,\"z\":805,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"126\"}},{\"x\":742,\"y\":123,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"127\"}},{\"x\":736,\"y\":129,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"128\"}},{\"x\":733,\"y\":138,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"129\"}},{\"x\":737,\"y\":134,\"z\":792,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"130\"}},{\"x\":741,\"y\":131,\"z\":799,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"131\"}},{\"x\":743,\"y\":129,\"z\":802,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"132\"}},{\"x\":753,\"y\":134,\"z\":804,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"133\"}},{\"x\":755,\"y\":139,\"z\":808,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"134\"}},{\"x\":757,\"y\":131,\"z\":798,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"135\"}},{\"x\":772,\"y\":140,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"136\"}},{\"x\":773,\"y\":144,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"137\"}},{\"x\":784,\"y\":142,\"z\":797,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"138\"}},{\"x\":785,\"y\":141,\"z\":795,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"139\"}},{\"x\":793,\"y\":147,\"z\":801,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"140\"}},{\"x\":785,\"y\":137,\"z\":810,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"141\"}},{\"x\":790,\"y\":133,\"z\":800,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"142\"}},{\"x\":806,\"y\":131,\"z\":803,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"143\"}},{\"x\":803,\"y\":131,\"z\":809,\"r\":0,\"g\":1,\"b\":0,\"options\":{\"name\":\"144\"}}]"; - WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, "crystal_hollows"); + WaypointGroup waypointGroup = Waypoints.fromColeweightJson(coleweightJson, Location.CRYSTAL_HOLLOWS); Assertions.assertEquals(SAPPHIRE_WAYOINTS, waypointGroup); } From 05d2a2683b549e09d1ca6ce730222d1c77085e0a Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 8 Oct 2024 02:09:46 -0400 Subject: [PATCH 15/18] Fix export translation key --- .../skyblocker/skyblock/waypoint/WaypointsShareScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java index fed71464ec..bc9102ca43 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsShareScreen.java @@ -53,7 +53,7 @@ protected void init() { Waypoints.LOGGER.error("[Skyblocker Waypoints] Encountered exception while serializing Skyblocker waypoint data", e); SystemToast.show(client.getToastManager(), Waypoints.WAYPOINTS_TOAST_TYPE, Text.translatable("skyblocker.waypoints.exportError"), Text.translatable("skyblocker.waypoints.exportErrorText")); } - }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.importWaypointsSkyblocker.tooltip"))).build()); + }).tooltip(Tooltip.of(Text.translatable("skyblocker.waypoints.exportWaypointsSkyblocker.tooltip"))).build()); adder.add(ButtonWidget.builder(Text.translatable("skyblocker.waypoints.importWaypointsSkytils"), buttonImport -> { try { List waypointGroups = Waypoints.fromSkytils(client.keyboard.getClipboard(), island); From cd74b78d5cabb2729c853e27e7b0acb8b1d38109 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:43:05 -0400 Subject: [PATCH 16/18] Refactor individual waypoint --- ...ntLocation.java => ChatPositionShare.java} | 51 +++++--- .../chat/chatcoords/ChatLocation.java | 26 ----- .../skyblock/waypoint/IndividualWaypoint.java | 110 +++++++++--------- .../assets/skyblocker/lang/en_us.json | 3 +- 4 files changed, 93 insertions(+), 97 deletions(-) rename src/main/java/de/hysky/skyblocker/skyblock/chat/{chatcoords/ChatWaypointLocation.java => ChatPositionShare.java} (51%) delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatLocation.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatWaypointLocation.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java similarity index 51% rename from src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatWaypointLocation.java rename to src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java index b291a76355..92f17a5fc9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatWaypointLocation.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatPositionShare.java @@ -1,14 +1,23 @@ -package de.hysky.skyblocker.skyblock.chat.chatcoords; +package de.hysky.skyblocker.skyblock.chat; +import com.mojang.brigadier.Command; import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.MessageScheduler; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.text.ClickEvent; +import net.minecraft.text.HoverEvent; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.math.Vec3d; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,9 +25,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public class ChatWaypointLocation { - - private static final Logger LOGGER = LoggerFactory.getLogger(ChatWaypointLocation.class); +public class ChatPositionShare { + private static final Logger LOGGER = LoggerFactory.getLogger(ChatPositionShare.class); private static final Pattern GENERIC_COORDS_PATTERN = Pattern.compile("x: (?-?[0-9]+), y: (?[0-9]+), z: (?-?[0-9]+)"); private static final Pattern SKYBLOCKER_COORDS_PATTERN = Pattern.compile("x: (?-?[0-9]+), y: (?[0-9]+), z: (?-?[0-9]+)(?: \\| (?[^|]+))"); @@ -27,12 +35,20 @@ public class ChatWaypointLocation { @Init public static void init() { - ClientReceiveMessageEvents.GAME.register(ChatWaypointLocation::onMessage); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( + ClientCommandManager.literal("skyblocker").then(ClientCommandManager.literal("sharePosition").executes(context -> sharePlayerPosition(context.getSource()))) + )); + ClientReceiveMessageEvents.GAME.register(ChatPositionShare::onMessage); } + private static int sharePlayerPosition(FabricClientCommandSource source) { + Vec3d pos = source.getPosition(); + MessageScheduler.INSTANCE.sendMessageAfterCooldown("x: " + (int) pos.getX() + ", y: " + (int) pos.getY() + ", z: " + (int) pos.getZ() + " | " + Utils.getIslandArea(), true); + return Command.SINGLE_SUCCESS; + } + private static void onMessage(Text text, boolean overlay) { if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.waypoints.enableWaypoints) { - String message = text.getString(); for (Pattern pattern : PATTERNS) { @@ -42,10 +58,10 @@ private static void onMessage(Text text, boolean overlay) { String x = matcher.group("x"); String y = matcher.group("y"); String z = matcher.group("z"); - String area = matcher.group("area"); + String area = matcher.namedGroups().containsKey("area") ? matcher.group("area") : ""; requestWaypoint(x, y, z, area); } catch (Exception e) { - LOGGER.error("[SKYBLOCKER CHAT WAYPOINTS] Error creating chat waypoint: ", e); + LOGGER.error("[Skyblocker Chat Waypoints] Error creating chat waypoint: ", e); } break; } @@ -53,14 +69,17 @@ private static void onMessage(Text text, boolean overlay) { } } - private static void requestWaypoint(String x, String y, String z, String area) { + private static void requestWaypoint(String x, String y, String z, @NotNull String area) { String command = "/skyblocker waypoints individual " + x + " " + y + " " + z + " " + area; - - Text text = Constants.PREFIX.get() - .append(Text.translatable("skyblocker.config.chat.waypoints.display").formatted(Formatting.AQUA) - .styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)))) - .append(Text.of(area != null ? " at " + area : "")); - - MinecraftClient.getInstance().player.sendMessage(text, false); + MutableText requestMessage = Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.display").formatted(Formatting.AQUA) + .styled(style -> style + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("skyblocker.config.chat.waypoints.display"))) + .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)) + ) + ); + if (!area.isEmpty()) { + requestMessage = requestMessage.append(" at ").append(Text.literal(area).formatted(Formatting.AQUA)); + } + MinecraftClient.getInstance().player.sendMessage(requestMessage, false); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatLocation.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatLocation.java deleted file mode 100644 index d519a414cd..0000000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/chatcoords/ChatLocation.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.hysky.skyblocker.skyblock.chat.chatcoords; - -import com.mojang.brigadier.Command; -import de.hysky.skyblocker.annotations.Init; -import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.scheduler.MessageScheduler; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public class ChatLocation { - @Init - public static void init() { - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - ClientCommandManager.literal("skyblocker").then(ClientCommandManager.literal("location").executes(context -> sharePlayerLocation())) - )); - } - - private static int sharePlayerLocation() { - ClientPlayerEntity thePlayer = MinecraftClient.getInstance().player; - MessageScheduler.INSTANCE.sendMessageAfterCooldown("x: " + (int) thePlayer.getX() + ", y: " + (int) thePlayer.getY() + ", z: " + (int) thePlayer.getZ() + " | " + Utils.getIslandArea(), true); - return Command.SINGLE_SUCCESS; - } - -} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java index 7a47037336..02fc24c29a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/IndividualWaypoint.java @@ -6,6 +6,7 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.utils.ColorUtils; +import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -16,69 +17,70 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import java.awt.*; +import java.util.function.Consumer; +/** + * One single temporary waypoint that gets deleted when the player gets close or changes world. + * Used for sharing positions from chat or other temporary uses. + */ public class IndividualWaypoint extends NamedWaypoint { + private static IndividualWaypoint waypoint; - private static IndividualWaypoint waypoint; + @Init + public static void init() { + ClientTickEvents.END_CLIENT_TICK.register(IndividualWaypoint::onTick); + WorldRenderEvents.AFTER_TRANSLUCENT.register(context -> {if (waypoint != null) waypoint.render(context);}); + ClientPlayConnectionEvents.JOIN.register((ignore, ignore2, ignore3) -> waypoint = null); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( + ClientCommandManager.literal(SkyblockerMod.NAMESPACE).then(ClientCommandManager.literal("waypoints").then(ClientCommandManager.literal("individual") + .then(ClientCommandManager.argument("x", IntegerArgumentType.integer(Integer.MIN_VALUE)) + .then(ClientCommandManager.argument("y", IntegerArgumentType.integer(Integer.MIN_VALUE)) + .then(ClientCommandManager.argument("z", IntegerArgumentType.integer(Integer.MIN_VALUE)) + .then(ClientCommandManager.argument("area", StringArgumentType.greedyString()) + .executes(context -> setWaypoint( + context.getSource()::sendFeedback, + IntegerArgumentType.getInteger(context, "x"), + IntegerArgumentType.getInteger(context, "y"), + IntegerArgumentType.getInteger(context, "z"), + StringArgumentType.getString(context, "area") + )) + ) + ) + ) + ) + ))) + ); + } - @Init - public static void init() { + public IndividualWaypoint(BlockPos pos, Text name, float[] colorComponents) { + super(pos, name, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, true); + } - ClientTickEvents.END_CLIENT_TICK.register(IndividualWaypoint::onTick); + private static int setWaypoint(Consumer feedback, int x, int y, int z, String area) { + setWaypoint(x, y, z, area); + feedback.accept(Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.displayed", x, y, z, area))); + return Command.SINGLE_SUCCESS; + } - WorldRenderEvents.AFTER_TRANSLUCENT.register(context -> { if (waypoint != null) waypoint.render(context); }); + private static void setWaypoint(int x, int y, int z, String area) { + String waypointName = area != null && !area.isEmpty() ? area : "Chat Waypoint"; - ClientPlayConnectionEvents.JOIN.register((ignore, ignore2, ignore3) -> waypoint = null); + Text waypointDisplay; + if (waypointName.charAt(0) == '⏣') { + waypointDisplay = Text.literal("⏣").formatted(Formatting.DARK_PURPLE) + .append(Text.literal(waypointName.substring(1)).formatted(Formatting.AQUA)); + } else { + waypointDisplay = Text.literal(waypointName).formatted(Formatting.AQUA); + } - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - ClientCommandManager.literal(SkyblockerMod.NAMESPACE) - .then(ClientCommandManager.literal("waypoints") - .then(ClientCommandManager.literal("individual") - .then(ClientCommandManager.argument("x", IntegerArgumentType.integer(Integer.MIN_VALUE)) - .then(ClientCommandManager.argument("y", IntegerArgumentType.integer(Integer.MIN_VALUE)) - .then(ClientCommandManager.argument("z", IntegerArgumentType.integer(Integer.MIN_VALUE)) - .then(ClientCommandManager.argument("area", StringArgumentType.greedyString()) - .executes(context -> setWaypoint( - IntegerArgumentType.getInteger(context, "x"), - IntegerArgumentType.getInteger(context, "y"), - IntegerArgumentType.getInteger(context, "z"), - StringArgumentType.getString(context, "area") - )) - ) - ) - ) - ) - ) - ) - )); - } - - public IndividualWaypoint(BlockPos pos, Text name, float[] colorComponents) { - super(pos, name, colorComponents, 0.5f, true); - } - - private static int setWaypoint(int x, int y, int z, String area) { - String waypointName = area != null && !area.isEmpty() ? area : "Waypoint"; - - Text waypointDisplay; - if (waypointName.charAt(0) == '⏣') { - waypointDisplay = Text.literal("⏣").formatted(Formatting.DARK_PURPLE) - .append(Text.literal(waypointName.substring(1)).formatted(Formatting.AQUA)); - } else { - waypointDisplay = Text.literal(waypointName).formatted(Formatting.AQUA); - } - - waypoint = new IndividualWaypoint(new BlockPos(x, y, z), waypointDisplay, ColorUtils.getFloatComponents(Color.GREEN.getRGB())); - return Command.SINGLE_SUCCESS; - } - - private static void onTick(MinecraftClient c) { - if (waypoint != null && c.player.getPos().distanceTo(Vec3d.ofCenter(waypoint.pos)) <= 8) { - waypoint = null; - } - } + waypoint = new IndividualWaypoint(new BlockPos(x, y, z), waypointDisplay, ColorUtils.getFloatComponents(Color.GREEN.getRGB())); + } + private static void onTick(MinecraftClient client) { + if (waypoint != null && client.player != null && client.player.squaredDistanceTo(waypoint.centerPos) <= 8) { + waypoint = null; + } + } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 3d97e1458c..17f11aa53c 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -469,7 +469,8 @@ "skyblocker.config.chat.chatRules.screen.ruleScreen.sounds.pling": "Pling", "skyblocker.config.chat.chatRules.screen.ruleScreen.sounds.zombie": "Zombie", "skyblocker.config.chat.chatRules.screen.ruleScreen.true": "True", - "skyblocker.config.chat.waypoints.display": "[Display Waypoint]", + "skyblocker.config.chat.waypoints.display": "[Click to Display Waypoint]", + "skyblocker.config.chat.waypoints.displayed": "Displayed temporary waypoint at x: %d, y: %d, z: %d | %s", "skyblocker.config.chat.filter": "Filter", From 3a75b3dd8baf805183645db2e546234152949251 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:22:42 -0800 Subject: [PATCH 17/18] Remove unused translation strings --- src/main/resources/assets/skyblocker/lang/en_us.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 17f11aa53c..f1251d13c6 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -536,8 +536,6 @@ "skyblocker.config.mining.commissionWaypoints.mode.BOTH": "Both", "skyblocker.config.mining.commissionWaypoints.useColor": "Colored Waypoints", "skyblocker.config.mining.commissionWaypoints.useColor.@Tooltip": "Color the waypoint text to match the block it's for.", - "skyblocker.config.mining.commissionWaypoints.textScale": "Text Scale", - "skyblocker.config.mining.commissionWaypoints.textScale.@Tooltip": "Scale the size of the commission labels.", "skyblocker.config.mining.commissionWaypoints.showBaseCamp": "Show Basecamp Waypoint", "skyblocker.config.mining.commissionWaypoints.showBaseCamp.@Tooltip": "Show waypoint for basecamp when in glacite tunnels (takes effect when commissions updated).", "skyblocker.config.mining.commissionWaypoints.showEmissary": "Show Emissary", @@ -565,8 +563,6 @@ "skyblocker.config.mining.crystalsWaypoints": "Crystal Hollows Waypoints", "skyblocker.config.mining.crystalsWaypoints.enabled": "Enabled Waypoints", "skyblocker.config.mining.crystalsWaypoints.enabled.@Tooltip": "Show a waypoint (waypoint selected in general/waypoints) at important areas in the crystal hollows, e.g., Jungle Temple and Fairy Grotto. ", - "skyblocker.config.mining.crystalsWaypoints.textScale": "Text Scale", - "skyblocker.config.mining.crystalsWaypoints.textScale.@Tooltip": "Scale the size of the commission labels.", "skyblocker.config.mining.crystalsWaypoints.findInChat": "Find Waypoints In Chat", "skyblocker.config.mining.crystalsWaypoints.findInChat.@Tooltip": "When in crystal hollows read the chat to see if coordinates are sent and extract these to show as waypoint or on the map", "skyblocker.config.mining.crystalsWaypoints.addedWaypoint": "Added waypoint for '%s' at %d %d %d.", From d276f871cfd39168beb5772299bb41061899ad9b Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:40:42 -0800 Subject: [PATCH 18/18] Update GoldorWaypointsManager --- .../skyblock/dungeon/GoldorWaypointsManager.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/GoldorWaypointsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/GoldorWaypointsManager.java index 6d995ce883..2fd04655c2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/GoldorWaypointsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/GoldorWaypointsManager.java @@ -11,6 +11,7 @@ import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.waypoint.NamedWaypoint; +import de.hysky.skyblocker.utils.waypoint.Waypoint; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -110,20 +111,15 @@ private static boolean shouldProcessMsgs() { * @param waypoints The list of waypoints to operate on * @param playerName The name of the player to check against */ - private static void removeNearestWaypoint(ObjectArrayList waypoints, String playerName) { + private static void removeNearestWaypoint(List waypoints, String playerName) { MinecraftClient client = MinecraftClient.getInstance(); if (client.world == null) return; + // Get the position of the player with the given name Optional posOptional = client.world.getPlayers().stream().filter(player -> player.getGameProfile().getName().equals(playerName)).findAny().map(Entity::getPos); - if (posOptional.isPresent()) { - Vec3d pos = posOptional.get(); - - waypoints.stream().filter(GoldorWaypoint::shouldRender).min(Comparator.comparingDouble(waypoint -> waypoint.centerPos.squaredDistanceTo(pos))).map(waypoint -> { - waypoint.setShouldRender(false); - return null; - }); - } + // Find the nearest waypoint to the player and hide it + posOptional.flatMap(pos -> waypoints.stream().filter(GoldorWaypoint::shouldRender).min(Comparator.comparingDouble(waypoint -> waypoint.centerPos.squaredDistanceTo(pos)))).ifPresent(Waypoint::setFound); } /** @@ -143,7 +139,7 @@ private static void reset() { * @param waypoints The set of waypoints to enable rendering for */ private static void enableAll(ObjectArrayList waypoints) { - waypoints.forEach(waypoint -> waypoint.setShouldRender(true)); + waypoints.forEach(Waypoint::setMissing); } /**