finish biome priority

This commit is contained in:
Jesse Boyd 2017-05-01 02:32:34 +10:00
parent f8579bdf6a
commit 94e5a931ec
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 21 additions and 2 deletions

View File

@ -45,6 +45,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
private char[] overlay; private char[] overlay;
private TextureUtil textureUtil; private TextureUtil textureUtil;
private boolean randomVariation = true; private boolean randomVariation = true;
private int biomePriority = 0;
private boolean modifiedMain = false; private boolean modifiedMain = false;
@ -260,6 +261,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
} }
} }
public void setBiomePriority(int value) {
this.biomePriority = ((value * 65536) / 100) - 32768;
}
public void setBlockAndBiomeColor(BufferedImage img) { public void setBlockAndBiomeColor(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
@ -275,7 +280,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements Extent {
BaseBlock block = textureUtil.getNearestBlock(color); BaseBlock block = textureUtil.getNearestBlock(color);
TextureUtil.BiomeColor biome = textureUtil.getNearestBiome(color); TextureUtil.BiomeColor biome = textureUtil.getNearestBiome(color);
int blockColor = textureUtil.getColor(block); int blockColor = textureUtil.getColor(block);
if (textureUtil.colorDistance(biome.grass, color) <= textureUtil.colorDistance(blockColor, color)) { if (textureUtil.colorDistance(biome.grass, color) - biomePriority <= textureUtil.colorDistance(blockColor, color)) {
byte biomeByte = (byte) biome.id; byte biomeByte = (byte) biome.id;
biomes[index] = biomeByte; biomes[index] = biomeByte;
if (yBiome && x > 0 && x < widthIndex) { if (yBiome && x > 0 && x < widthIndex) {

View File

@ -152,6 +152,7 @@ public class CreateFromImage extends Command {
fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteComplexity <min=0> <max=100>"); fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteComplexity <min=0> <max=100>");
fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteRandomization <true|false>"); fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteRandomization <true|false>");
fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteBlocks <block-list>"); fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteBlocks <block-list>");
fp.sendMessage(BBC.getPrefix() + "/2 cfi paletteBiomePriority <percent=50>");
fp.sendMessage(BBC.getPrefix() + "/2 cfi done"); fp.sendMessage(BBC.getPrefix() + "/2 cfi done");
fp.sendMessage(BBC.getPrefix() + "/2 cfi cancel"); fp.sendMessage(BBC.getPrefix() + "/2 cfi cancel");
File folder = new File(PS.imp().getWorldContainer(), plot.getWorldName() + File.separator + "region"); File folder = new File(PS.imp().getWorldContainer(), plot.getWorldName() + File.separator + "region");
@ -245,6 +246,19 @@ public class CreateFromImage extends Command {
player.sendMessage("Set color palette blocks, what's next?"); player.sendMessage("Set color palette blocks, what's next?");
return; return;
} }
case "biomepriority":
case "palettebiomepriority":
case "setpalettebiomepriority": {
// roughness
// blocks
if (argList.size() != 2) {
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <percent=50>");
return;
}
generator.setBiomePriority(Integer.parseInt(argList.get(1)));
player.sendMessage("Set color palette biome priority, what's next?");
return;
}
case "color": case "color":
case "setcolor": { case "setcolor": {
if (argList.size() != 2) { if (argList.size() != 2) {
@ -482,7 +496,7 @@ public class CreateFromImage extends Command {
player.sendMessage(BBC.getPrefix() + "Cancelled!"); player.sendMessage(BBC.getPrefix() + "Cancelled!");
return; return;
default: default:
C.COMMAND_SYNTAX.send(player, "/2 cfi <setBiome|setOverlay|setMain|setFloor|setColumn|addCaves|addOre[s]|addSchems|setHeight|setColor|setGlassColor|setBiomeColor|setBlockAndBiomeColor|setColorPaletteComplexity|setColorPaletteRandomization|setColorPaletteBlocks|done|cancel|>"); C.COMMAND_SYNTAX.send(player, "/2 cfi <setBiome|setOverlay|setMain|setFloor|setColumn|addCaves|addOre[s]|addSchems|setHeight|setColor|setGlassColor|setBiomeColor|setBlockAndBiomeColor|setColorPaletteComplexity|setColorPaletteRandomization|setColorPaletteBlocks|biomepriority|done|cancel|>");
return; return;
} }
} catch (IOException e) { } catch (IOException e) {