From 9db42fb0dbf041f7b79593bf8004a6921cf00950 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Wed, 8 Feb 2023 16:53:36 +0100 Subject: [PATCH] fix: rare double aura in desert temples --- build.gradle | 2 +- .../dev/tilera/auracore/aura/AuraManager.java | 33 +++++++++++++++++++ .../tilera/auracore/world/WorldGenerator.java | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4d4eeed..4e14d46 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ apply from: './gradle/scripts/mixins.gradle' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 -version = "1.8.6" +version = "1.8.7" group= "dev.tilera" archivesBaseName = "auracore" diff --git a/src/main/java/dev/tilera/auracore/aura/AuraManager.java b/src/main/java/dev/tilera/auracore/aura/AuraManager.java index 7109349..1a35572 100644 --- a/src/main/java/dev/tilera/auracore/aura/AuraManager.java +++ b/src/main/java/dev/tilera/auracore/aura/AuraManager.java @@ -228,6 +228,39 @@ public class AuraManager { return closest; } + public static int getClosestAuraWithinRange(World world, double x, double z, double range) { + int dim = world.provider.dimensionId; + int cx = MathHelper.floor_double((double)x) / 16; + int cz = MathHelper.floor_double((double)z) / 16; + if (world.isRemote) { + return -1; + } + int size = 5; + int closest = -1; + double clRange = Double.MAX_VALUE; + synchronized (saveLock) { + for (int xx = -size; xx <= size; ++xx) { + for (int zz = -size; zz <= size; ++zz) { + List nc = nodeChunks.get(Arrays.asList(dim, cx + xx, cz + zz)); + if (nc == null || nc.size() <= 0) continue; + for (Integer key : nc) { + try { + double zd; + double xd; + double distSq; + AuraNode node = AuraManager.copyNode(AuraManager.getNode(key)); + if (node == null || node.locked || !Utils.isChunkLoaded(world, MathHelper.floor_double((double)node.xPos), MathHelper.floor_double((double)node.zPos)) || !(range * range >= (distSq = (xd = node.xPos - x) * xd + (zd = node.zPos - z) * zd)) || !(distSq < clRange)) continue; + closest = key; + clRange = distSq; + } + catch (Exception e) {} + } + } + } + } + return closest; + } + public static ArrayList getAurasWithin(World world, double x, double y, double z) { int dim = world.provider.dimensionId; int cx = MathHelper.floor_double((double)x) / 16; diff --git a/src/main/java/dev/tilera/auracore/world/WorldGenerator.java b/src/main/java/dev/tilera/auracore/world/WorldGenerator.java index cb7511c..696d5a4 100644 --- a/src/main/java/dev/tilera/auracore/world/WorldGenerator.java +++ b/src/main/java/dev/tilera/auracore/world/WorldGenerator.java @@ -98,7 +98,7 @@ public class WorldGenerator implements IWorldGenerator { auraGen = true; this.structureNode.put(var7.hashCode(), true); int yPos = world.getHeightValue(var7.chunkPosX, var7.chunkPosZ) + 3; - int nearKey = AuraManager.getClosestAuraWithinRange(world, var7.chunkPosX, yPos, var7.chunkPosZ, 10); + int nearKey = AuraManager.getClosestAuraWithinRange(world, var7.chunkPosX, var7.chunkPosZ, 10); if (nearKey < 0 && yPos > 0) { int value = random.nextInt(200) + 800; AuraManager.registerAuraNode(world, (short)value, EnumNodeType.NORMAL, world.provider.dimensionId, var7.chunkPosX, yPos, var7.chunkPosZ);