From 3768ce270333a49e3b7428fb25077a67841692ef Mon Sep 17 00:00:00 2001 From: Desoroxxx Date: Sat, 7 Oct 2023 01:06:55 +0200 Subject: [PATCH] Added compatibility layer for mods using older versions At least I do not need to face transition hell anymore --- Changelog.md | 5 + build.gradle.kts | 3 +- .../redstudio/redcore/logging/RedLogger.java | 4 +- .../redcore/utils/math/MathUtil.java | 10 +- mc/build.gradle.kts | 7 +- .../dev/redstudio/redcore/RedCorePlugin.java | 3 +- .../io/redstudioragnarok/redcore/RedCore.java | 33 +++ .../redcore/logging/RedLogger.java | 45 ++++ .../redcore/ticking/RedClientTickEvent.java | 53 ++++ .../redcore/ticking/RedClientTicker.java | 44 ++++ .../redcore/utils/MathUtil.java | 236 ++++++++++++++++++ .../redcore/utils/NetworkUtil.java | 19 ++ .../redcore/utils/OptiNotFine.java | 30 +++ .../redcore/vectors/Vector2D.java | 67 +++++ .../redcore/vectors/Vector2F.java | 69 +++++ .../redcore/vectors/Vector2I.java | 67 +++++ .../redcore/vectors/Vector3D.java | 186 ++++++++++++++ .../redcore/vectors/Vector3F.java | 186 ++++++++++++++ .../redcore/vectors/Vector3I.java | 207 +++++++++++++++ 19 files changed, 1264 insertions(+), 10 deletions(-) create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/RedCore.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/logging/RedLogger.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTickEvent.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTicker.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/utils/MathUtil.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/utils/NetworkUtil.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/utils/OptiNotFine.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2D.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2F.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2I.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3D.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3F.java create mode 100644 mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3I.java diff --git a/Changelog.md b/Changelog.md index addcd5e..976db47 100644 --- a/Changelog.md +++ b/Changelog.md @@ -21,11 +21,16 @@ Red Core and its Minecraft parts have been separated into two, this allows for g - `MathUtil` is now under `utils.math` - Separated `MathUtil` clamping methods into their own class `ClampUtil` - Changed GroupId from `io.redstudioragnarok` to `dev.redstudio` +- Made `RedLogger#RANDOM` private ### Removed - Removed `Stopwatch` :sob: it wasn't that good or useful but was fun to make +### Fixed + +- Fixed inconsistent argument naming in `MathUtil#lerp` + ### Internal - Switched to [gradle-buildconfig-plugin](https://github.com/gmazzo/gradle-buildconfig-plugin) entirely for project constants diff --git a/build.gradle.kts b/build.gradle.kts index 9403457..69201b2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,8 @@ allprojects { // Azul covers the most platforms for Java 8 toolchains, crucially including macOS arm64 vendor.set(JvmVendorSpec.AZUL) } - withJavadocJar() + // Generate sources jar when building + withSourcesJar() } tasks.withType().configureEach { diff --git a/core/src/main/java/dev/redstudio/redcore/logging/RedLogger.java b/core/src/main/java/dev/redstudio/redcore/logging/RedLogger.java index 7071f6a..ff8effc 100644 --- a/core/src/main/java/dev/redstudio/redcore/logging/RedLogger.java +++ b/core/src/main/java/dev/redstudio/redcore/logging/RedLogger.java @@ -16,7 +16,7 @@ */ public class RedLogger { - public static final Random RANDOM = new Random(); + private static final Random RANDOM = new Random(); /** * A list of recomfort messages to be displayed when an error occurs. @@ -86,7 +86,7 @@ public RedLogger(final String modName, final String newIssueLink, final Logger l * * @deprecated Use a String instead of an URI for the newIssueLink parameter. To be removed in 0.4 */ - @Deprecated // Use a String instead of an URI for the newIssueLink parameter. To be removed in 0.4 + @Deprecated // Use a String instead of an URI for the newIssueLink parameter. Todo: Removed in 0.4 public RedLogger(final String modName, final URI newIssueLink, final Logger logger, final String... customRecomfortMessages) { this.modName = modName; this.newIssueLink = newIssueLink.toString(); diff --git a/core/src/main/java/dev/redstudio/redcore/utils/math/MathUtil.java b/core/src/main/java/dev/redstudio/redcore/utils/math/MathUtil.java index 4d3d28c..e35cb12 100644 --- a/core/src/main/java/dev/redstudio/redcore/utils/math/MathUtil.java +++ b/core/src/main/java/dev/redstudio/redcore/utils/math/MathUtil.java @@ -8,7 +8,7 @@ * @author Desoroxxx * @since 0.2 */ -@SuppressWarnings({"unused"}) +@SuppressWarnings("unused") public final class MathUtil { /** @@ -176,13 +176,13 @@ public static float lerp(final float startValue, final float partialTicks, final /** * Performs a linear interpolation between two values. * - * @param input The starting value. + * @param startValue The starting value. * @param partialTicks The fraction of the tick that has passed. - * @param target The target value. + * @param targetValue The target value. * @return The interpolated value. */ - public static double lerp(final double input, final double partialTicks, final double target) { - return input + (target - input) * partialTicks; + public static double lerp(final double startValue, final double partialTicks, final double targetValue) { + return startValue + (targetValue - startValue) * partialTicks; } /** diff --git a/mc/build.gradle.kts b/mc/build.gradle.kts index 2450874..cdc42e7 100644 --- a/mc/build.gradle.kts +++ b/mc/build.gradle.kts @@ -32,9 +32,14 @@ tasks.named("jar") { ) } - archiveBaseName = "!Red-Core-1.12" + archiveBaseName = "!Red-Core-1.12.2" } +tasks.named("sourcesJar") { + archiveBaseName.set("!Red-Core-1.12.2") +} + + publishing.publications.register("redCoreMc", MavenPublication::class) { from(components["java"]) diff --git a/mc/src/main/java/dev/redstudio/redcore/RedCorePlugin.java b/mc/src/main/java/dev/redstudio/redcore/RedCorePlugin.java index 73f87cc..04d7b60 100644 --- a/mc/src/main/java/dev/redstudio/redcore/RedCorePlugin.java +++ b/mc/src/main/java/dev/redstudio/redcore/RedCorePlugin.java @@ -9,7 +9,8 @@ import javax.annotation.Nullable; import java.util.Map; -import static dev.redstudio.redcore.ProjectConstants.*; +import static dev.redstudio.redcore.ProjectConstants.NAME; +import static dev.redstudio.redcore.ProjectConstants.VERSION; // /$$$$$$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$ // | $$__ $$ | $$ /$$__ $$ | $$$ /$$$ /$$__ $$ diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/RedCore.java b/mc/src/main/java/io/redstudioragnarok/redcore/RedCore.java new file mode 100644 index 0000000..bdac2c6 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/RedCore.java @@ -0,0 +1,33 @@ +package io.redstudioragnarok.redcore; + +import dev.redstudio.redcore.utils.OptiNotFine; +import io.redstudioragnarok.redcore.ticking.RedClientTicker; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +public final class RedCore { + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTicker#startClientTicker} + */ + @Deprecated + @SideOnly(Side.CLIENT) + public static void startClientTicker() { + MinecraftForge.EVENT_BUS.register(RedClientTicker.class); + } + + /** + * @deprecated Use {@link OptiNotFine#forceOptiFineFastRenderOff} + */ + @Deprecated + @SideOnly(Side.CLIENT) + public static void forceOptiFineFastRenderOff() { + OptiNotFine.forceOptiFineFastRenderOff(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/logging/RedLogger.java b/mc/src/main/java/io/redstudioragnarok/redcore/logging/RedLogger.java new file mode 100644 index 0000000..bb578ba --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/logging/RedLogger.java @@ -0,0 +1,45 @@ +package io.redstudioragnarok.redcore.logging; + +import org.apache.logging.log4j.Logger; + +import java.net.URI; +import java.util.Random; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +public final class RedLogger extends dev.redstudio.redcore.logging.RedLogger { + + /** + * @deprecated Use your own random + */ + @Deprecated + public static final Random RANDOM = new Random(); + + /** + * @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#RedLogger(String, String, Logger, String...)} + */ + @Deprecated + public RedLogger(final String modName, final String newIssueLink, final Logger logger, final String... customRecomfortMessages) { + super(modName, newIssueLink, logger, customRecomfortMessages); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#RedLogger(String, URI, Logger, String...)} + */ + @Deprecated + public RedLogger(final String modName, final URI newIssueLink, final Logger logger, final String... customRecomfortMessages) { + super(modName, newIssueLink, logger, customRecomfortMessages); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#printFramedError} + */ + @Override + @Deprecated + public void printFramedError(final String category, final String whatHappened, final String whatNow, final String... additionalInformation) { + super.printFramedError(category, whatHappened, whatNow, additionalInformation); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTickEvent.java b/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTickEvent.java new file mode 100644 index 0000000..3ac2303 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTickEvent.java @@ -0,0 +1,53 @@ +package io.redstudioragnarok.redcore.ticking; + +import net.minecraftforge.fml.common.eventhandler.Event; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +public class RedClientTickEvent extends Event { + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.BiTickEvent} + */ + @Deprecated + public static class BiTickEvent extends RedClientTickEvent { + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.BiTickEvent#BiTickEvent()} + */ + @Deprecated + public BiTickEvent() { + } + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.PentaTickEvent} + */ + @Deprecated + public static class PentaTickEvent extends RedClientTickEvent { + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.PentaTickEvent#PentaTickEvent()} + */ + @Deprecated + public PentaTickEvent() { + } + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.DecaTickEvent} + */ + @Deprecated + public static class DecaTickEvent extends RedClientTickEvent { + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.DecaTickEvent#DecaTickEvent()} + */ + @Deprecated + public DecaTickEvent() { + } + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTicker.java b/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTicker.java new file mode 100644 index 0000000..d3c797c --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/ticking/RedClientTicker.java @@ -0,0 +1,44 @@ +package io.redstudioragnarok.redcore.ticking; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +public class RedClientTicker { + + private static int biTickCount, pentaTickCount, decaTickCount; + + /** + * @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTicker#onClientTickEvent} + */ + @Deprecated + @SubscribeEvent(priority = EventPriority.HIGHEST) + public static void onClientTickEvent(TickEvent.ClientTickEvent clientTickEvent) { + if (clientTickEvent.phase == TickEvent.Phase.START) { + + biTickCount++; + if (biTickCount == 2) { + MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.BiTickEvent()); + biTickCount = 0; + } + + pentaTickCount++; + if (pentaTickCount == 5) { + MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.PentaTickEvent()); + pentaTickCount = 0; + } + + decaTickCount++; + if (decaTickCount == 10) { + MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.DecaTickEvent()); + decaTickCount = 0; + } + } + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/utils/MathUtil.java b/mc/src/main/java/io/redstudioragnarok/redcore/utils/MathUtil.java new file mode 100644 index 0000000..7ed5b0c --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/utils/MathUtil.java @@ -0,0 +1,236 @@ +package io.redstudioragnarok.redcore.utils; + +import dev.redstudio.redcore.utils.math.ClampUtil; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class MathUtil { + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMinFirst} + */ + @Deprecated + public static float clampMinFirst(final float input, final float min, final float max) { + return ClampUtil.clampMinFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMaxFirst} + */ + @Deprecated + public static float clampMaxFirst(final float input, final float min, final float max) { + return ClampUtil.clampMaxFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampTest} + */ + @Deprecated + public static float clampTest(final float input, final float min, final float max) { + return ClampUtil.clampTest(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMinFirst} + */ + @Deprecated + public static double clampMinFirst(final double input, final double min, final double max) { + return ClampUtil.clampMinFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMaxFirst} + */ + @Deprecated + public static double clampMaxFirst(final double input, final double min, final double max) { + return ClampUtil.clampMaxFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampTest} + */ + @Deprecated + public static double clampTest(final double input, final double min, final double max) { + return ClampUtil.clampTest(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMinFirst} + */ + @Deprecated + public static byte clampMinFirst(final byte input, final byte min, final byte max) { + return ClampUtil.clampMinFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMaxFirst} + */ + @Deprecated + public static byte clampMaxFirst(final byte input, final byte min, final byte max) { + return ClampUtil.clampMaxFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampTest} + */ + @Deprecated + public static byte clampTest(final byte input, final byte min, final byte max) { + return ClampUtil.clampTest(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMinFirst} + */ + @Deprecated + public static short clampMinFirst(final short input, final short min, final short max) { + return ClampUtil.clampMinFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMaxFirst} + */ + @Deprecated + public static short clampMaxFirst(final short input, final short min, final short max) { + return ClampUtil.clampMaxFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampTest} + */ + @Deprecated + public static short clampTest(final short input, final short min, final short max) { + return ClampUtil.clampTest(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMinFirst} + */ + @Deprecated + public static int clampMinFirst(final int input, final int min, final int max) { + return ClampUtil.clampMinFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampMaxFirst} + */ + @Deprecated + public static int clampMaxFirst(final int input, final int min, final int max) { + return ClampUtil.clampMaxFirst(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.ClampUtil#clampTest} + */ + @Deprecated + public static int clampTest(final int input, final int min, final int max) { + return ClampUtil.clampTest(input, min, max); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#absolute} + */ + @Deprecated + public static float absolute(final float input) { + return dev.redstudio.redcore.utils.math.MathUtil.absolute(input); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#absolute} + */ + @Deprecated + public static double absolute(final double input) { + return dev.redstudio.redcore.utils.math.MathUtil.absolute(input); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#absoluteMax} + */ + @Deprecated + public static float absoluteMax(final float input1, final float input2) { + return dev.redstudio.redcore.utils.math.MathUtil.absoluteMax(input1, input2); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#absoluteMax} + */ + @Deprecated + public static double absoluteMax(final double input1, final double input2) { + return dev.redstudio.redcore.utils.math.MathUtil.absoluteMax(input1, input2); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#addOrSubtractBasedOnSign} + */ + @Deprecated + public static float addOrSubtractBasedOnSign(final float input, final float add) { + return dev.redstudio.redcore.utils.math.MathUtil.addOrSubtractBasedOnSign(input, add); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#addOrSubtractBasedOnSign} + */ + @Deprecated + public static double addOrSubtractBasedOnSign(final double input, final double add) { + return dev.redstudio.redcore.utils.math.MathUtil.addOrSubtractBasedOnSign(input, add); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#round} + */ + @Deprecated + public static float round(final float input, final int decimals) { + return dev.redstudio.redcore.utils.math.MathUtil.round(input, decimals); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#round} + */ + @Deprecated + public static double round(final double input, final int decimals) { + return dev.redstudio.redcore.utils.math.MathUtil.round(input, decimals); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#floorToInt} + */ + @Deprecated + public static int floorToInt(final float input) { + return dev.redstudio.redcore.utils.math.MathUtil.floorToInt(input); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#floorToInt} + */ + @Deprecated + public static int floorToInt(final double input) { + return dev.redstudio.redcore.utils.math.MathUtil.floorToInt(input); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#lerp} + */ + @Deprecated + public static float lerp(final float startValue, final float partialTicks, final float targetValue) { + return dev.redstudio.redcore.utils.math.MathUtil.lerp(startValue, partialTicks, targetValue); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#lerp} + */ + @Deprecated + public static double lerp(final double startValue, final double partialTicks, final double targetValue) { + return dev.redstudio.redcore.utils.math.MathUtil.lerp(startValue, partialTicks, targetValue); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.math.MathUtil#boolToInt} + */ + @Deprecated + public static int boolToInt(final boolean input) { + return dev.redstudio.redcore.utils.math.MathUtil.boolToInt(input); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/utils/NetworkUtil.java b/mc/src/main/java/io/redstudioragnarok/redcore/utils/NetworkUtil.java new file mode 100644 index 0000000..d8c0399 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/utils/NetworkUtil.java @@ -0,0 +1,19 @@ +package io.redstudioragnarok.redcore.utils; + +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +public final class NetworkUtil { + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.NetworkUtil#processMessage} + */ + @Deprecated + public static void processMessage(final MessageContext messageContext, final Runnable runnable) { + dev.redstudio.redcore.utils.NetworkUtil.processMessage(messageContext, runnable); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/utils/OptiNotFine.java b/mc/src/main/java/io/redstudioragnarok/redcore/utils/OptiNotFine.java new file mode 100644 index 0000000..55eb380 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/utils/OptiNotFine.java @@ -0,0 +1,30 @@ +package io.redstudioragnarok.redcore.utils; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SideOnly(Side.CLIENT) +@SuppressWarnings("unused") +public final class OptiNotFine { + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.OptiNotFine#isOptiFineInstalled()} + */ + @Deprecated + public static boolean isOptiFineInstalled() { + return dev.redstudio.redcore.utils.OptiNotFine.isOptiFineInstalled(); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.utils.OptiNotFine#shadersEnabled} + */ + @Deprecated + public static boolean shadersEnabled() { + return dev.redstudio.redcore.utils.OptiNotFine.shadersEnabled(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2D.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2D.java new file mode 100644 index 0000000..cd91a4b --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2D.java @@ -0,0 +1,67 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.minecraft.util.math.Vec2f; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector2D { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#x} + */ + public double x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#y} + */ + public double y; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#Vector2D()} + */ + public Vector2D() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#Vector2D(double, double)} + */ + public Vector2D(final double inputX, final double inputY) { + x = inputX; + y = inputY; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#Vector2D(Vec2f)} + */ + public Vector2D(final Vec2f input) { + x = input.x; + y = input.y; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#zero()} + */ + public void zero() { + x = y = 0; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeDouble(x); + byteBuf.writeDouble(y); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2D#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readDouble(); + y = byteBuf.readDouble(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2F.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2F.java new file mode 100644 index 0000000..b6444b0 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2F.java @@ -0,0 +1,69 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.minecraft.util.math.Vec2f; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector2F { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#x} + */ + public float x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#y} + */ + public float y; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#Vector2F()} + */ + public Vector2F() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#Vector2F(float, float)} + */ + public Vector2F(final float inputX, final float inputY) { + x = inputX; + y = inputY; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#Vector2F(Vec2f)} + */ + public Vector2F(final Vec2f input) { + x = input.x; + y = input.y; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#zero()} + */ + public void zero() { + x = y = 0; + } + + /*===================================== NETWORKING =====================================*/ + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeFloat(x); + byteBuf.writeFloat(y); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2F#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readFloat(); + y = byteBuf.readFloat(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2I.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2I.java new file mode 100644 index 0000000..e512e84 --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector2I.java @@ -0,0 +1,67 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.minecraft.util.math.Vec2f; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector2I { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#x} + */ + public int x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#y} + */ + public int y; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#Vector2I()} + */ + public Vector2I() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#Vector2I(int, int)} + */ + public Vector2I(final int inputX, final int inputY) { + x = inputX; + y = inputY; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#Vector2I(Vec2f)} + */ + public Vector2I(final Vec2f input) { + x = (int) input.x; + y = (int) input.y; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#zero()} + */ + public void zero() { + x = y = 0; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeInt(x); + byteBuf.writeInt(y); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector2I#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readInt(); + y = byteBuf.readInt(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3D.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3D.java new file mode 100644 index 0000000..2e2f34a --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3D.java @@ -0,0 +1,186 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.jafama.FastMath; +import net.minecraft.util.math.Vec3d; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector3D { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#x} + */ + public double x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#y} + */ + public double y; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#z} + */ + public double z; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#Vector3D()} + */ + public Vector3D() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#Vector3D(double, double, double)} + */ + public Vector3D(final double inputX, final double inputY, final double inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#Vector3D(dev.redstudio.redcore.vectors.Vector3D)} + */ + public Vector3D(final Vector3D input) { + x = input.x; + y = input.y; + z = input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#Vector3D(dev.redstudio.redcore.vectors.Vector3F)} + */ + public Vector3D(final Vector3F input) { + x = input.x; + y = input.y; + z = input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#Vector3D(Vec3d)} + */ + public Vector3D(final Vec3d input) { + x = input.x; + y = input.y; + z = input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#toVec3d()} + */ + public Vec3d toVec3d() { + return new Vec3d(x, y, z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#zero()} + */ + public void zero() { + x = y = z = 0; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#copy(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void copy(final Vector3D inputVector) { + x = inputVector.x; + y = inputVector.y; + z = inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#copy(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void copy(final Vector3F inputVector) { + x = inputVector.x; + y = inputVector.y; + z = inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#set(double, double, double)} + */ + public void set(final double inputX, final double inputY, final double inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#add(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void add(final Vector3D inputVector) { + x += inputVector.x; + y += inputVector.y; + z += inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#add(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void add(final Vector3F inputVector) { + x += inputVector.x; + y += inputVector.y; + z += inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#scale(double)} + */ + public void scale(final double multiplier) { + x *= multiplier; + y *= multiplier; + z *= multiplier; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#lerp(dev.redstudio.redcore.vectors.Vector3D, float, dev.redstudio.redcore.vectors.Vector3D)} + */ + public void lerp(final Vector3D input, final float partialTicks, final Vector3D target) { + x = input.x + (target.x - input.x) * partialTicks; + y = input.y + (target.y - input.y) * partialTicks; + z = input.z + (target.z - input.z) * partialTicks; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#distanceTo(dev.redstudio.redcore.vectors.Vector3D)} + */ + public double distanceTo(final Vector3D target) { + final double xDelta = target.x - x; + final double yDelta = target.y - y; + final double zDelta = target.z - z; + + return FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#distanceTo(dev.redstudio.redcore.vectors.Vector3F)} + */ + public double distanceTo(final Vector3F target) { + final double xDelta = target.x - x; + final double yDelta = target.y - y; + final double zDelta = target.z - z; + + return FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeDouble(x); + byteBuf.writeDouble(y); + byteBuf.writeDouble(z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3D#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readDouble(); + y = byteBuf.readDouble(); + z = byteBuf.readDouble(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3F.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3F.java new file mode 100644 index 0000000..f53053c --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3F.java @@ -0,0 +1,186 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.jafama.FastMath; +import net.minecraft.util.math.Vec3d; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector3F { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#x} + */ + public float x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#y} + */ + public float y; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#z} + */ + public float z; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#Vector3F()} + */ + public Vector3F() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#Vector3F(float, float, float)} + */ + public Vector3F(final float inputX, final float inputY, final float inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#Vector3F(dev.redstudio.redcore.vectors.Vector3F)} + */ + public Vector3F(final Vector3F input) { + x = input.x; + y = input.y; + z = input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#Vector3F(dev.redstudio.redcore.vectors.Vector3D)} + */ + public Vector3F(final Vector3D input) { + x = (float) input.x; + y = (float) input.y; + z = (float) input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#Vector3F(Vec3d)} + */ + public Vector3F(final Vec3d input) { + x = (float) input.x; + y = (float) input.y; + z = (float) input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#toVec3d()} + */ + public Vec3d toVec3d() { + return new Vec3d(x, y, z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#zero()} + */ + public void zero() { + x = y = z = 0; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#copy(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void copy(final Vector3F inputVector) { + x = inputVector.x; + y = inputVector.y; + z = inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#copy(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void copy(final Vector3D inputVector) { + x = (float) inputVector.x; + y = (float) inputVector.y; + z = (float) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#set(float, float, float)} + */ + public void set(final float inputX, final float inputY, final float inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#add(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void add(final Vector3F inputVector) { + x += inputVector.x; + y += inputVector.y; + z += inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#add(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void add(final Vector3D inputVector) { + x += (float) inputVector.x; + y += (float) inputVector.y; + z += (float) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#scale(float)} + */ + public void scale(final float multiplier) { + x *= multiplier; + y *= multiplier; + z *= multiplier; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#lerp(dev.redstudio.redcore.vectors.Vector3F, float, dev.redstudio.redcore.vectors.Vector3F)} + */ + public void lerp(final Vector3F input, final float partialTicks, final Vector3F target) { + x = input.x + (target.x - input.x) * partialTicks; + y = input.y + (target.y - input.y) * partialTicks; + z = input.z + (target.z - input.z) * partialTicks; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#distanceTo(dev.redstudio.redcore.vectors.Vector3F)} + */ + public float distanceTo(final Vector3F target) { + final float xDelta = target.x - x; + final float yDelta = target.y - y; + final float zDelta = target.z - z; + + return (float) FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#distanceTo(dev.redstudio.redcore.vectors.Vector3D)} + */ + public float distanceTo(final Vector3D target) { + final float xDelta = (float) (target.x - x); + final float yDelta = (float) (target.y - y); + final float zDelta = (float) (target.z - z); + + return (float) FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeFloat(x); + byteBuf.writeFloat(y); + byteBuf.writeFloat(z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3F#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readFloat(); + y = byteBuf.readFloat(); + z = byteBuf.readFloat(); + } +} diff --git a/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3I.java b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3I.java new file mode 100644 index 0000000..df8f5af --- /dev/null +++ b/mc/src/main/java/io/redstudioragnarok/redcore/vectors/Vector3I.java @@ -0,0 +1,207 @@ +package io.redstudioragnarok.redcore.vectors; + +import io.netty.buffer.ByteBuf; +import net.jafama.FastMath; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3i; + +/** + * @author Luna Lage (Desoroxxx) + * @deprecated See methods for details. + */ +@Deprecated +@SuppressWarnings("unused") +public final class Vector3I { + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#x} + */ + public int x; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#y} + */ + public int y; + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#z} + */ + public int z; + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#Vector3I()} + */ + public Vector3I() { + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#Vector3I(int, int, int)} + */ + public Vector3I(final int inputX, final int inputY, final int inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#Vector3I(dev.redstudio.redcore.vectors.Vector3D)} + */ + public Vector3I(final Vector3D input) { + x = (int) input.x; + y = (int) input.y; + z = (int) input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#Vector3I(dev.redstudio.redcore.vectors.Vector3F)} + */ + public Vector3I(final Vector3F input) { + x = (int) input.x; + y = (int) input.y; + z = (int) input.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#Vector3I(Vec3i)} + */ + public Vector3I(final Vec3i input) { + x = input.getX(); + y = input.getY(); + z = input.getZ(); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#toVec3d()} + */ + public Vec3d toVec3d() { + return new Vec3d(x, y, z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#zero()} + */ + public void zero() { + x = y = z = 0; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#copy(dev.redstudio.redcore.vectors.Vector3I)} + */ + public void copy(final Vector3I inputVector) { + x = inputVector.x; + y = inputVector.y; + z = inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#copy(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void copy(final Vector3D inputVector) { + x = (int) inputVector.x; + y = (int) inputVector.y; + z = (int) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#copy(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void copy(final Vector3F inputVector) { + x = (int) inputVector.x; + y = (int) inputVector.y; + z = (int) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#set(int, int, int)} + */ + public void set(final int inputX, final int inputY, final int inputZ) { + x = inputX; + y = inputY; + z = inputZ; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#add(dev.redstudio.redcore.vectors.Vector3D)} + */ + public void add(final Vector3D inputVector) { + x += (int) inputVector.x; + y += (int) inputVector.y; + z += (int) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#add(dev.redstudio.redcore.vectors.Vector3F)} + */ + public void add(final Vector3F inputVector) { + x += (int) inputVector.x; + y += (int) inputVector.y; + z += (int) inputVector.z; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#scale(int)} + */ + public void scale(final int multiplier) { + x *= multiplier; + y *= multiplier; + z *= multiplier; + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#lerp(dev.redstudio.redcore.vectors.Vector3I, float, dev.redstudio.redcore.vectors.Vector3I)} + */ + public void lerp(final Vector3I input, final float partialTicks, final Vector3I target) { + x = (int) (input.x + (target.x - input.x) * partialTicks); + y = (int) (input.y + (target.y - input.y) * partialTicks); + z = (int) (input.z + (target.z - input.z) * partialTicks); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#distanceTo(dev.redstudio.redcore.vectors.Vector3I)} + */ + public int distanceTo(final Vector3I target) { + final int xDelta = target.x - x; + final int yDelta = target.y - y; + final int zDelta = target.z - z; + + return (int) FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#distanceTo(dev.redstudio.redcore.vectors.Vector3D)} + */ + public int distanceTo(final Vector3D target) { + final int xDelta = (int) (target.x - x); + final int yDelta = (int) (target.y - y); + final int zDelta = (int) (target.z - z); + + return (int) FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#distanceTo(dev.redstudio.redcore.vectors.Vector3F)} + */ + public int distanceTo(final Vector3F target) { + final int xDelta = (int) (target.x - x); + final int yDelta = (int) (target.y - y); + final int zDelta = (int) (target.z - z); + + return (int) FastMath.sqrt(xDelta * xDelta + yDelta * yDelta + zDelta * zDelta); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#write(ByteBuf)} + */ + public void write(final ByteBuf byteBuf) { + byteBuf.writeInt(x); + byteBuf.writeInt(y); + byteBuf.writeInt(z); + } + + /** + * @deprecated Use {@link dev.redstudio.redcore.vectors.Vector3I#read(ByteBuf)} + */ + public void read(final ByteBuf byteBuf) { + x = byteBuf.readInt(); + y = byteBuf.readInt(); + z = byteBuf.readInt(); + } +}