begin refactoring with Tectonic Object Templates

This commit is contained in:
dfsek
2021-01-30 03:22:13 -07:00
parent c834d80206
commit af248ee14a
20 changed files with 224 additions and 145 deletions

View File

@@ -145,7 +145,7 @@ public class DistributionTest {
.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
.registerLoader(TerraBiome.class, biomeRegistry);
new GenericLoaders(null).register(pipeLoader);
pipeLoader.registerLoader(NoiseSeeded.class, new NoiseSamplerBuilderLoader(folderLoader));
pipeLoader.registerLoader(NoiseSeeded.class, new NoiseSamplerBuilderLoader());
pipeLoader.load(template, folderLoader.get("pack.yml"));
return template.getBiomeProviderBuilder().build(seed);
@@ -214,6 +214,7 @@ public class DistributionTest {
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar() == 's') {
long l = System.nanoTime();
try {
provider[0] = getProvider(ThreadLocalRandom.current().nextLong());
} catch(ConfigException | IOException configException) {
@@ -225,6 +226,9 @@ public class DistributionTest {
image[0].setRGB(x, z, provider[0].getBiome(x, z).getColor());
}
}
long n = System.nanoTime();
double t = n - l;
System.out.println("Time: " + t / 1000000 + "ms");
img.setIcon(new ImageIcon(image[0]));
}
}

View File

@@ -8,6 +8,7 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.config.GenericLoaders;
import com.dfsek.terra.config.fileloaders.FolderLoader;
import com.dfsek.terra.config.loaders.ProbabilityCollectionLoader;
import com.dfsek.terra.config.loaders.config.BufferedImageLoader;
import com.dfsek.terra.config.loaders.config.sampler.NoiseSamplerBuilderLoader;
import org.apache.commons.io.FileUtils;
@@ -95,7 +96,8 @@ public class NoiseTool {
FolderLoader folderLoader = new FolderLoader(Paths.get("./"));
ConfigLoader loader = new ConfigLoader();
loader.registerLoader(NoiseSeeded.class, new NoiseSamplerBuilderLoader(folderLoader))
loader.registerLoader(NoiseSeeded.class, new NoiseSamplerBuilderLoader())
.registerLoader(BufferedImage.class, new BufferedImageLoader(folderLoader))
.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader());
new GenericLoaders(null).register(loader);
@@ -124,6 +126,7 @@ public class NoiseTool {
ProbabilityCollection<Integer> colorCollection = color.getColors();
loader.load(template, new FileInputStream(file));
System.out.println(template.getBuilder().getDimensions());
NoiseSampler noise = template.getBuilder().apply((long) seed);
int size = 1024;