diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-05-14 22:58:56 -0400 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2024-05-24 19:51:46 -0400 |
commit | 7bf3958477c179185f9532cebffc36f218aa3bd8 (patch) | |
tree | 375325e936948bf088de79c049fd26d91ccb9e24 /src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java | |
parent | e9bd404a36ce3a69e62e97986d42e7f3635ab67d (diff) | |
download | Skyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.tar.gz Skyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.tar.bz2 Skyblocker-7bf3958477c179185f9532cebffc36f218aa3bd8.zip |
Port waypoints config screens
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java | 40 |
1 files changed, 36 insertions, 4 deletions
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 75e2edcf..c991fb9c 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -3,10 +3,12 @@ package de.hysky.skyblocker.utils.waypoint; 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.util.StringIdentifiable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import java.util.Arrays; +import java.util.Objects; import java.util.function.Supplier; public class Waypoint implements Renderable { @@ -16,9 +18,9 @@ public class Waypoint implements Renderable { final Box box; final Supplier<Type> typeSupplier; protected final float[] colorComponents; - final float alpha; - final float lineWidth; - final boolean throughWalls; + public final float alpha; + public final float lineWidth; + public final boolean throughWalls; private boolean shouldRender; public Waypoint(BlockPos pos, Type type, float[] colorComponents) { @@ -56,6 +58,22 @@ public class Waypoint implements Renderable { this.shouldRender = shouldRender; } + public Waypoint withX(int x) { + return new Waypoint(new BlockPos(x, pos.getY(), pos.getZ()), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + } + + public Waypoint withY(int y) { + return new Waypoint(pos.withY(y), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + } + + public Waypoint withZ(int z) { + return new Waypoint(new BlockPos(pos.getX(), pos.getY(), z), typeSupplier, getColorComponents(), alpha, lineWidth, throughWalls, shouldRender()); + } + + public Waypoint withColor(float[] colorComponents, float alpha) { + return new Waypoint(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, shouldRender()); + } + public boolean shouldRender() { return shouldRender; } @@ -72,6 +90,10 @@ public class Waypoint implements Renderable { this.shouldRender = !this.shouldRender; } + public void setShouldRender(boolean shouldRender) { + this.shouldRender = shouldRender; + } + public float[] getColorComponents() { return colorComponents; } @@ -96,11 +118,16 @@ public class Waypoint implements Renderable { } @Override + public int hashCode() { + return Objects.hash(pos, typeSupplier.get(), Arrays.hashCode(colorComponents), alpha, lineWidth, throughWalls, shouldRender); + } + + @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; } - public enum Type { + public enum Type implements StringIdentifiable { WAYPOINT, OUTLINED_WAYPOINT, HIGHLIGHT, @@ -108,6 +135,11 @@ public class Waypoint implements Renderable { OUTLINE; @Override + public String asString() { + return name().toLowerCase(); + } + + @Override public String toString() { return switch (this) { case WAYPOINT -> "Waypoint"; |