From 2f963e86efd2fd4d174c0bad58583c6c48ccd8c6 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Tue, 23 Jul 2024 17:45:37 +0200 Subject: [PATCH] Add clone method to vector data types --- .../sosengine/base/types/vectors/Vec2.java | 13 +++++++++++++ .../sosengine/base/types/vectors/Vec2i.java | 15 ++++++++++++++- .../sosengine/base/types/vectors/Vec3.java | 13 +++++++++++++ .../sosengine/base/types/vectors/Vec3i.java | 13 +++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java index d8e3481f..c4dfe8d2 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java @@ -21,6 +21,7 @@ package de.staropensource.sosengine.base.types.vectors; import lombok.Getter; import lombok.Setter; +import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; /** @@ -82,6 +83,18 @@ public class Vec2 { this.y = y; } + /** + * Creates an identical copy of this vector. + * + * @return identical copy + * @since v1-alpha2 + */ + @SneakyThrows + @NotNull + public Vec2 clone() { + return (Vec2) super.clone(); + } + /** * Returns a string representation of this vector. * diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java index bf5816b9..3b822722 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java @@ -21,6 +21,7 @@ package de.staropensource.sosengine.base.types.vectors; import lombok.Getter; import lombok.Setter; +import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; /** @@ -31,7 +32,7 @@ import org.jetbrains.annotations.NotNull; @SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" }) @Getter @Setter -public class Vec2i { +public class Vec2i implements Cloneable { /** * The X axis value. * @@ -82,6 +83,18 @@ public class Vec2i { this.y = y; } + /** + * Creates an identical copy of this vector. + * + * @return identical copy + * @since v1-alpha2 + */ + @SneakyThrows + @NotNull + public Vec2i clone() { + return (Vec2i) super.clone(); + } + /** * Returns a string representation of this vector. * diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java index 882c32f1..2fdcd621 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java @@ -21,6 +21,7 @@ package de.staropensource.sosengine.base.types.vectors; import lombok.Getter; import lombok.Setter; +import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; /** @@ -103,6 +104,18 @@ public class Vec3 { this.z = z; } + /** + * Creates an identical copy of this vector. + * + * @return identical copy + * @since v1-alpha2 + */ + @SneakyThrows + @NotNull + public Vec3 clone() { + return (Vec3) super.clone(); + } + /** * Returns a string representation of this vector. * diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java index e0102e11..42b6baf1 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java @@ -21,6 +21,7 @@ package de.staropensource.sosengine.base.types.vectors; import lombok.Getter; import lombok.Setter; +import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; /** @@ -103,6 +104,18 @@ public class Vec3i { this.z = z; } + /** + * Creates an identical copy of this vector. + * + * @return identical copy + * @since v1-alpha2 + */ + @SneakyThrows + @NotNull + public Vec3i clone() { + return (Vec3i) super.clone(); + } + /** * Returns a string representation of this vector. *