mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 09:16:34 +00:00
cleanup
This commit is contained in:
@@ -90,4 +90,8 @@ public final class MathUtil {
|
||||
|
||||
return Math.sqrt(((xVal2 - xVal1) * (xVal2 - xVal1)) + ((zVal2 - zVal1) * (zVal2 - zVal1)) + ((yVal2 - yVal1) * (yVal2 - yVal1)));
|
||||
}
|
||||
|
||||
public static long squash(int first, int last) {
|
||||
return (((long) first) << 32) | (last & 0xffffffffL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ChunkCoordinate implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof com.dfsek.terra.api.world.generation.population.ChunkCoordinate)) return false;
|
||||
if(!(obj instanceof ChunkCoordinate)) return false;
|
||||
com.dfsek.terra.api.world.generation.population.ChunkCoordinate other = (com.dfsek.terra.api.world.generation.population.ChunkCoordinate) obj;
|
||||
return other.getX() == x && other.getZ() == z;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CarverCache {
|
||||
|
||||
public List<Worm.WormPoint> getPoints(int chunkX, int chunkZ, UserDefinedCarver carver) {
|
||||
synchronized(carvers) {
|
||||
return carvers.computeIfAbsent((((long) chunkX) << 32) | (chunkZ & 0xffffffffL), key -> {
|
||||
return carvers.computeIfAbsent(MathUtil.squash(chunkX, chunkZ), key -> {
|
||||
TerraBiomeGrid grid = main.getWorld(w).getGrid();
|
||||
if(carver.isChunkCarved(w, chunkX, chunkZ, new FastRandom(MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed() + carver.hashCode())))) {
|
||||
long seed = MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.generation.math;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import net.jafama.FastMath;
|
||||
@@ -53,7 +54,7 @@ public class SamplerCache {
|
||||
}
|
||||
|
||||
public Sampler getChunk(int cx, int cz) {
|
||||
long key = (((long) cx) << 32) | (cz & 0xffffffffL);
|
||||
long key = MathUtil.squash(cx, cz);
|
||||
synchronized(cache) {
|
||||
return cache.computeIfAbsent(key, k -> new Sampler(cx, cz, terraWorld.getGrid(), world, terraWorld.getConfig().getTemplate().getBaseBlend(), terraWorld.getConfig().getTemplate().getElevationBlend()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user