mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-13 11:16:05 +00:00
mostly working 1.17-ification
This commit is contained in:
@@ -5,12 +5,15 @@ import com.dfsek.terra.api.world.palette.Palette;
|
||||
|
||||
public class PaletteHolder {
|
||||
private final Palette<BlockData>[] palettes;
|
||||
private final int offset;
|
||||
|
||||
protected PaletteHolder(Palette<BlockData>[] palettes) {
|
||||
protected PaletteHolder(Palette<BlockData>[] palettes, int offset) {
|
||||
this.palettes = palettes;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Palette<BlockData> getPalette(int y) {
|
||||
return palettes[y];
|
||||
int index = y + offset;
|
||||
return index >= 0 ? palettes[index] : palettes[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ public class PaletteHolderBuilder {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"})
|
||||
public PaletteHolder build() {
|
||||
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1];
|
||||
|
||||
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
|
||||
Palette<BlockData>[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
|
||||
for(int y = 0; y <= FastMath.max(paletteMap.lastKey(), 255); y++) {
|
||||
Palette<BlockData> d = null;
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
|
||||
@@ -27,8 +30,8 @@ public class PaletteHolderBuilder {
|
||||
}
|
||||
}
|
||||
if(d == null) throw new IllegalArgumentException("No palette for Y=" + y);
|
||||
palettes[y] = d;
|
||||
palettes[y - min] = d;
|
||||
}
|
||||
return new PaletteHolder(palettes);
|
||||
return new PaletteHolder(palettes, -min);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
}
|
||||
|
||||
for(int y = 0; y < size + 1; y++) {
|
||||
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, y << 2, (z << 2) + zOrigin);
|
||||
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, (y << 2) + min, (z << 2) + zOrigin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,10 +98,10 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
*/
|
||||
@Override
|
||||
public double getNoise(double x, double y, double z) {
|
||||
return interpGrid[reRange(((int) x) / 4, 3)][FastMath.max(FastMath.min(((int) y), max), min) / 4][reRange(((int) z) / 4, 3)].trilerp((x % 4) / 4, (y % 4) / 4, (z % 4) / 4);
|
||||
return interpGrid[reRange(((int) x) / 4, 3)][(FastMath.max(FastMath.min(((int) y), max), min) - min) / 4][reRange(((int) z) / 4, 3)].trilerp((x % 4) / 4, (y % 4) / 4, (z % 4) / 4);
|
||||
}
|
||||
|
||||
public double getNoise(int x, int y, int z) {
|
||||
return interpGrid[x / 4][y / 4][z / 4].trilerp((double) (x % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
|
||||
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp((double) (x % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user