-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Caching heightmaps in order to use for another generators
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/terra121/dataset/HeightmapModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.terra121.dataset; | ||
|
||
import io.github.opencubicchunks.cubicchunks.api.util.CubePos; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class HeightmapModel { | ||
public boolean surface; | ||
public double[][] heightmap; | ||
|
||
private HeightmapModel() {} | ||
|
||
public HeightmapModel(boolean surface, double[][] heightmap) { | ||
this.heightmap = heightmap; | ||
this.surface = surface; | ||
} | ||
|
||
private static Map<CubePos, HeightmapModel> cachedHeightmaps = new HashMap<>(); | ||
|
||
public static HeightmapModel getModel(int chunkX, int chunkY, int chunkZ) { | ||
return getModel(new CubePos(chunkX, chunkY, chunkZ)); | ||
} | ||
|
||
public static HeightmapModel getModel(CubePos pos) { | ||
if(!cachedHeightmaps.containsKey(pos)) | ||
return null; | ||
|
||
return cachedHeightmaps.get(pos); | ||
} | ||
|
||
public static void add(CubePos pos, HeightmapModel model) { | ||
cachedHeightmaps.put(pos, model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters