mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-12 10:46:25 +00:00
Finalize commands, add to GUI
This commit is contained in:
@@ -32,11 +32,12 @@ public class DebugFrame extends JFrame implements ActionListener {
|
||||
super.paintComponents(g);
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
if(! (p.getWorld().getGenerator() instanceof TerraChunkGenerator)) break;
|
||||
int xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX(), x) / x) * getWidth());
|
||||
int zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ(), z) / z) * getHeight());
|
||||
if(WorldConfig.fromWorld(p.getWorld()).imageLoader.getAlign().equals(ImageLoader.Align.CENTER)) {
|
||||
xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth());
|
||||
zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight());
|
||||
int xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth());
|
||||
int zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight());
|
||||
ImageLoader loader = WorldConfig.fromWorld(p.getWorld()).imageLoader;
|
||||
if(loader != null && loader.getAlign().equals(ImageLoader.Align.NONE)) {
|
||||
xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX(), x) / x) * getWidth());
|
||||
zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ(), z) / z) * getHeight());
|
||||
}
|
||||
String str = BiomeConfig.fromBiome((UserDefinedBiome) TerraBiomeGrid.fromWorld(p.getWorld()).getBiome(p.getLocation(), GenerationPhase.POPULATE)).getID();
|
||||
g.setColor(new Color(255, 255, 255, 128));
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.dfsek.terra.image;
|
||||
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.polydev.gaea.biome.NormalizationUtil;
|
||||
|
||||
@@ -38,21 +40,37 @@ public class ImageLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public void debug(boolean genStep, World w) {
|
||||
BufferedImage newImg = copyImage(image);
|
||||
public static void debugWorld(boolean genStep, World w) {
|
||||
if(!ConfigUtil.debug) return;
|
||||
BufferedImage newImg = new WorldImageGenerator(w, 1024, 1024).drawWorld(0, 0).getDraw();
|
||||
if(genStep) newImg = redrawStepped(newImg, w, Align.CENTER);
|
||||
DebugGUI debugGUI = new DebugGUI(newImg);
|
||||
debugGUI.start();
|
||||
}
|
||||
private static BufferedImage redrawStepped(BufferedImage original, World w, Align align) {
|
||||
BufferedImage newImg = copyImage(original);
|
||||
TerraBiomeGrid tb = TerraBiomeGrid.fromWorld(w);
|
||||
BiomeZone z = BiomeZone.fromWorld(w);
|
||||
if(genStep) {
|
||||
for(int x = 0; x < newImg.getWidth(); x++) {
|
||||
for(int y = 0; y < newImg.getHeight(); y++) {
|
||||
float[] noise = tb.getGrid(x, y).getRawNoise(x, y);
|
||||
newImg.setRGB(x, y, new Color((int) (NormalizationUtil.normalize(noise[0], tb.getGrid(x, y).getSizeX()) * ((double) 255/tb.getGrid(x, y).getSizeX())),
|
||||
(int) (NormalizationUtil.normalize(noise[1], tb.getGrid(x, y).getSizeZ()) * ((double) 255/tb.getGrid(x, y).getSizeZ())),
|
||||
(int) (z.getNoise(x, y) * ((double) 255/32)))
|
||||
.getRGB());
|
||||
}
|
||||
for(int x = 0; x < newImg.getWidth(); x++) {
|
||||
for(int y = 0; y < newImg.getHeight(); y++) {
|
||||
float[] noise;
|
||||
if(align.equals(Align.CENTER)) noise = tb.getGrid(x - original.getWidth()/2, y - original.getHeight()/2).getRawNoise(x - original.getWidth()/2, y - original.getHeight()/2);
|
||||
else noise = tb.getGrid(x, y).getRawNoise(x, y);
|
||||
newImg.setRGB(x, y, new Color((int) (NormalizationUtil.normalize(noise[0], tb.getGrid(x, y).getSizeX()) * ((double) 255 / tb.getGrid(x, y).getSizeX())),
|
||||
(int) (NormalizationUtil.normalize(noise[1], tb.getGrid(x, y).getSizeZ()) * ((double) 255 / tb.getGrid(x, y).getSizeZ())),
|
||||
(int) (NormalizationUtil.normalize(z.getNoise(x, y), z.getSize()) * ((double) 255 / z.getSize())))
|
||||
.getRGB());
|
||||
}
|
||||
}
|
||||
return newImg;
|
||||
}
|
||||
|
||||
public void debug(boolean genStep, World w) {
|
||||
if(!ConfigUtil.debug) return;
|
||||
BufferedImage newImg = copyImage(image);
|
||||
if(genStep) {
|
||||
newImg = redrawStepped(image, w, align);
|
||||
}
|
||||
DebugGUI debugGUI = new DebugGUI(newImg);
|
||||
debugGUI.start();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class WorldImageGenerator {
|
||||
draw = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
this.w = w;
|
||||
}
|
||||
public void drawWorld(int centerX, int centerZ) {
|
||||
public WorldImageGenerator drawWorld(int centerX, int centerZ) {
|
||||
TerraBiomeGrid tb = TerraBiomeGrid.fromWorld(w);
|
||||
int imY = 0;
|
||||
for(int y = centerZ - (draw.getHeight()/2); y < centerZ + (draw.getHeight()/2); y++) {
|
||||
@@ -33,7 +33,13 @@ public class WorldImageGenerator {
|
||||
}
|
||||
imY++;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BufferedImage getDraw() {
|
||||
return draw;
|
||||
}
|
||||
|
||||
public void save(File file) {
|
||||
try {
|
||||
ImageIO.write(draw, "png", file);
|
||||
|
||||
Reference in New Issue
Block a user