diff --git a/README.MD b/README.MD index f6acf1d9e..afbe2be63 100644 --- a/README.MD +++ b/README.MD @@ -11,7 +11,7 @@ # Required Dependencies * [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14 -* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.2.9 +* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.3.2 * NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below. # Known (temporary) Incompatibilities diff --git a/dependencies.gradle b/dependencies.gradle index d4a7b9e1b..79dc28d2f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -58,7 +58,7 @@ dependencies { // Iris Shaders compileOnly('org.jetbrains:annotations:24.0.1') - api("com.github.GTNewHorizons:GTNHLib:0.2.9:dev") + api("com.github.GTNewHorizons:GTNHLib:0.3.2:dev") shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0 implementation("io.github.douira:glsl-transformer:1.0.0") shadowImplementation("io.github.douira:glsl-transformer:1.0.0") { // glsl-transformer Noncommercial License 1.0.0 diff --git a/src/main/java/com/gtnewhorizons/angelica/AngelicaMod.java b/src/main/java/com/gtnewhorizons/angelica/AngelicaMod.java index 32763a0a5..2bbd6e824 100644 --- a/src/main/java/com/gtnewhorizons/angelica/AngelicaMod.java +++ b/src/main/java/com/gtnewhorizons/angelica/AngelicaMod.java @@ -15,7 +15,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; name = "Angelica", version = Tags.VERSION, dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);" - + " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.2.9,);", + + " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.3.2,);", acceptedMinecraftVersions = "[1.7.10]", acceptableRemoteVersions = "*", guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory") diff --git a/src/main/java/com/gtnewhorizons/angelica/api/BlockPos.java b/src/main/java/com/gtnewhorizons/angelica/api/BlockPos.java index 519b1e669..580284e30 100644 --- a/src/main/java/com/gtnewhorizons/angelica/api/BlockPos.java +++ b/src/main/java/com/gtnewhorizons/angelica/api/BlockPos.java @@ -1,24 +1,10 @@ package com.gtnewhorizons.angelica.api; +import com.gtnewhorizon.gtnhlib.util.CoordinatePacker; import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl; -import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; -import java.math.RoundingMode; - -import static com.google.common.math.IntMath.log2; - public interface BlockPos { - - int SIZE_BITS_X = 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY); - int SIZE_BITS_Z = SIZE_BITS_X; - int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z; - long BITS_X = (1L << SIZE_BITS_X) - 1L; - long BITS_Y = (1L << SIZE_BITS_Y) - 1L; - long BITS_Z = (1L << SIZE_BITS_Z) - 1L; - int BIT_SHIFT_Z = SIZE_BITS_Y; - int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z; - int getX(); int getY(); int getZ(); @@ -28,22 +14,6 @@ public interface BlockPos { long asLong(); static long asLong(int x, int y, int z) { - long l = 0L; - l |= ((long) x & BITS_X) << BIT_SHIFT_X; - l |= ((long) y & BITS_Y) << 0; - l |= ((long) z & BITS_Z) << BIT_SHIFT_Z; - return l; - } - - public static int unpackLongX(long packedPos) { - return (int)(packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X); - } - - public static int unpackLongY(long packedPos) { - return (int)(packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y); - } - - public static int unpackLongZ(long packedPos) { - return (int)(packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z); + return CoordinatePacker.pack(x, y, z); } } diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockPosImpl.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockPosImpl.java index 803ba32f2..61eb1b96e 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockPosImpl.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockPosImpl.java @@ -1,14 +1,11 @@ package com.gtnewhorizons.angelica.compat.mojang; -import com.gtnewhorizons.angelica.api.BlockPos; +import com.gtnewhorizon.gtnhlib.util.CoordinatePacker; import com.gtnewhorizons.angelica.api.MutableBlockPos; import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import org.joml.Vector3i; -import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongX; -import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongY; -import static com.gtnewhorizons.angelica.api.BlockPos.unpackLongZ; // Should we keep this? public class BlockPosImpl extends Vector3i implements MutableBlockPos { @@ -54,7 +51,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos { @Override public long asLong() { - return BlockPos.asLong(this.x, this.y, this.z); + return CoordinatePacker.pack(this.x, this.y, this.z); } @Override @@ -65,6 +62,7 @@ public class BlockPosImpl extends Vector3i implements MutableBlockPos { @Override public BlockPosImpl set(long packedPos) { - return set(unpackLongX(packedPos), unpackLongY(packedPos), unpackLongZ(packedPos)); + CoordinatePacker.unpack(packedPos, this); + return this; } } diff --git a/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java b/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java index 63dffc098..2c6404335 100644 --- a/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java +++ b/src/main/java/com/gtnewhorizons/angelica/dynamiclights/DynamicLights.java @@ -1,6 +1,6 @@ package com.gtnewhorizons.angelica.dynamiclights; -import com.gtnewhorizons.angelica.api.BlockPos; +import com.gtnewhorizon.gtnhlib.util.CoordinatePacker; import com.gtnewhorizons.angelica.compat.ModStatus; import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl; import com.gtnewhorizons.angelica.config.AngelicaConfig; @@ -278,7 +278,7 @@ public class DynamicLights { * @param chunkPos the packed chunk position */ public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, long chunkPos) { - scheduleChunkRebuild(renderer, BlockPos.unpackLongX(chunkPos), BlockPos.unpackLongY(chunkPos), BlockPos.unpackLongZ(chunkPos)); + scheduleChunkRebuild(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos)); } public static void scheduleChunkRebuild(@NotNull SodiumWorldRenderer renderer, int x, int y, int z) { @@ -294,7 +294,7 @@ public class DynamicLights { */ public static void updateTrackedChunks(@NotNull BlockPosImpl chunkPos, @Nullable LongOpenHashSet old, @Nullable LongOpenHashSet newPos) { if (old != null || newPos != null) { - long pos = chunkPos.asLong(); + final long pos = chunkPos.asLong(); if (old != null) old.remove(pos); if (newPos != null)