fix: rare double aura in desert temples
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Timo Ley 2023-02-08 16:53:36 +01:00
parent d9a56272f7
commit 9db42fb0db
3 changed files with 35 additions and 2 deletions

View File

@ -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"

View File

@ -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<Integer> 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<Integer> getAurasWithin(World world, double x, double y, double z) {
int dim = world.provider.dimensionId;
int cx = MathHelper.floor_double((double)x) / 16;

View File

@ -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);