use of org.dynmap.common.BiomeMap in project dynmap by webbukkit.
the class TexturePack method loadTextureFile.
/**
* Load texture pack mappings from texture.txt file
*/
private static void loadTextureFile(InputStream txtfile, String txtname, ConfigurationNode config, DynmapCore core, String blockset) {
LineNumberReader rdr = null;
int cnt = 0;
HashMap<String, Integer> filetoidx = new HashMap<String, Integer>();
HashMap<String, Integer> varvals = new HashMap<String, Integer>();
final String mcver = core.getDynmapPluginPlatformVersion();
boolean mod_cfg_needed = false;
boolean mod_cfg_loaded = false;
// Default to minecraft base
String modname = "minecraft";
String modversion = null;
String texturemod = null;
String texturepath = null;
boolean terrain_ok = true;
BlockStateParser bsp = new BlockStateParser();
Map<DynmapBlockState, BitSet> bsprslt;
try {
String line;
rdr = new LineNumberReader(new InputStreamReader(txtfile));
while ((line = rdr.readLine()) != null) {
boolean skip = false;
int lineNum = rdr.getLineNumber();
if ((line.length() > 0) && (line.charAt(0) == '[')) {
// If version constrained like
// Find end
int end = line.indexOf(']');
if (end < 0) {
Log.severe("Format error - line " + lineNum + " of " + txtname + ": bad version limit");
return;
}
String vertst = line.substring(1, end);
String tver = mcver;
if (vertst.startsWith("mod:")) {
// If mod version ranged
tver = modversion;
vertst = vertst.substring(4);
}
if (!HDBlockModels.checkVersionRange(tver, vertst)) {
skip = true;
}
line = line.substring(end + 1);
}
if (line.startsWith("#") || line.startsWith(";")) {
skip = true;
}
// If we're skipping due to version restriction
if (skip)
continue;
// Split off <type>:
int typeend = line.indexOf(':');
String typeid = "";
if (typeend >= 0) {
typeid = line.substring(0, typeend);
line = line.substring(typeend + 1).trim();
}
if (typeid.equals("block")) {
// Parse block states
bsp.processLine(modname, line, lineNum, varvals);
int srctxtid = TXTID_TERRAINPNG;
if (!terrain_ok)
// Mark as not usable
srctxtid = TXTID_INVALID;
int[] faces = new int[] { TILEINDEX_BLANK, TILEINDEX_BLANK, TILEINDEX_BLANK, TILEINDEX_BLANK, TILEINDEX_BLANK, TILEINDEX_BLANK };
int[] txtidx = new int[] { -1, -1, -1, -1, -1, -1 };
byte[] layers = null;
BlockTransparency trans = BlockTransparency.OPAQUE;
int colorMult = 0;
int blockColorIdx = -1;
// Legacy top/bottom rotation
boolean stdrot = false;
CustomColorMultiplier custColorMult = null;
String[] args = line.split(",");
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
else if (av[0].equals("txtid")) {
if (filetoidx.containsKey(av[1]))
srctxtid = filetoidx.get(av[1]);
else
Log.severe("Format error - line " + lineNum + " of " + txtname + ": bad texture " + av[1]);
}
}
bsprslt = bsp.getMatchingStates();
if (bsprslt.size() > 0) {
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
if (av[0].equals("top") || av[0].equals("y-") || av[0].equals("face1")) {
faces[BlockStep.Y_MINUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("bottom") || av[0].equals("y+") || av[0].equals("face0")) {
faces[BlockStep.Y_PLUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("north") || av[0].equals("x+") || av[0].equals("face4")) {
faces[BlockStep.X_PLUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("south") || av[0].equals("x-") || av[0].equals("face5")) {
faces[BlockStep.X_MINUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("west") || av[0].equals("z-") || av[0].equals("face3")) {
faces[BlockStep.Z_MINUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("east") || av[0].equals("z+") || av[0].equals("face2")) {
faces[BlockStep.Z_PLUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].startsWith("face")) {
int fid0, fid1;
String idrange = av[0].substring(4);
String[] ids = idrange.split("-");
if (ids.length > 1) {
fid0 = Integer.parseInt(ids[0]);
fid1 = Integer.parseInt(ids[1]);
} else {
fid0 = fid1 = Integer.parseInt(ids[0]);
}
if ((fid0 < 0) || (fid1 < fid0)) {
Log.severe("Texture mapping has invalid face index - " + av[1] + " - line " + lineNum + " of " + txtname);
return;
}
int[] faceToOrd = { BlockStep.Y_PLUS.ordinal(), BlockStep.Y_MINUS.ordinal(), BlockStep.Z_PLUS.ordinal(), BlockStep.Z_MINUS.ordinal(), BlockStep.X_PLUS.ordinal(), BlockStep.X_MINUS.ordinal() };
int txtid = parseTextureIndex(filetoidx, srctxtid, av[1]);
for (int i = fid0; (i <= fid1) && (i < 6); i++) {
faces[faceToOrd[i]] = txtid;
}
} else if (av[0].equals("allfaces")) {
int id = parseTextureIndex(filetoidx, srctxtid, av[1]);
for (int i = 0; i < 6; i++) {
faces[i] = id;
}
} else if (av[0].equals("allsides")) {
int id = parseTextureIndex(filetoidx, srctxtid, av[1]);
faces[BlockStep.X_PLUS.ordinal()] = id;
faces[BlockStep.X_MINUS.ordinal()] = id;
faces[BlockStep.Z_PLUS.ordinal()] = id;
faces[BlockStep.Z_MINUS.ordinal()] = id;
} else if (av[0].equals("topbottom")) {
faces[BlockStep.Y_MINUS.ordinal()] = faces[BlockStep.Y_PLUS.ordinal()] = parseTextureIndex(filetoidx, srctxtid, av[1]);
} else if (av[0].equals("blockcolor")) {
if (filetoidx.containsKey(av[1]))
blockColorIdx = filetoidx.get(av[1]);
else
Log.severe("Format error - line " + lineNum + " of " + txtname + ": bad texture " + av[1]);
} else if (av[0].startsWith("patch")) {
int patchid0, patchid1;
String idrange = av[0].substring(5);
String[] ids = idrange.split("-");
if (ids.length > 1) {
patchid0 = Integer.parseInt(ids[0]);
patchid1 = Integer.parseInt(ids[1]);
} else {
patchid0 = patchid1 = Integer.parseInt(ids[0]);
}
if ((patchid0 < 0) || (patchid1 < patchid0)) {
Log.severe("Texture mapping has invalid patch index - " + av[1] + " - line " + lineNum + " of " + txtname);
return;
}
if (faces.length <= patchid1) {
int[] newfaces = new int[patchid1 + 1];
Arrays.fill(newfaces, TILEINDEX_BLANK);
System.arraycopy(faces, 0, newfaces, 0, faces.length);
faces = newfaces;
int[] newtxtidx = new int[patchid1 + 1];
Arrays.fill(newtxtidx, -1);
System.arraycopy(txtidx, 0, newtxtidx, 0, txtidx.length);
txtidx = newtxtidx;
}
int txtid = parseTextureIndex(filetoidx, srctxtid, av[1]);
for (int i = patchid0; i <= patchid1; i++) {
faces[i] = txtid;
}
} else if (av[0].equals("transparency")) {
trans = BlockTransparency.valueOf(av[1]);
if (trans == null) {
trans = BlockTransparency.OPAQUE;
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + lineNum + " of " + txtname);
}
/* For leaves, base on leaf transparency setting */
if (trans == BlockTransparency.LEAVES) {
if (core.getLeafTransparency())
trans = BlockTransparency.TRANSPARENT;
else
trans = BlockTransparency.OPAQUE;
}
} else if (av[0].equals("colorMult")) {
colorMult = (int) Long.parseLong(av[1], 16);
} else if (av[0].equals("custColorMult")) {
try {
Class<?> cls = Class.forName(av[1]);
custColorMult = (CustomColorMultiplier) cls.newInstance();
} catch (Exception x) {
Log.severe("Error loading custom color multiplier - " + av[1] + ": " + x.getMessage());
}
} else if (av[0].equals("stdrot")) {
stdrot = av[1].equals("true");
}
}
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
if (av[0].startsWith("layer")) {
if (layers == null) {
layers = new byte[faces.length];
Arrays.fill(layers, (byte) -1);
}
String[] v = av[0].substring(5).split("-");
int id1, id2;
id1 = id2 = Integer.parseInt(v[0]);
if (v.length > 1) {
id2 = Integer.parseInt(v[1]);
}
byte val = (byte) Integer.parseInt(av[1]);
for (; id1 <= id2; id1++) {
layers[id1] = val;
}
}
}
/* If we have everything, build block */
if (bsprslt.size() > 0) {
Integer colorIndex = (blockColorIdx >= 0) ? (blockColorIdx + IMG_CNT) : null;
HDBlockStateTextureMap map = new HDBlockStateTextureMap(faces, layers, colorMult, custColorMult, blockset, stdrot, colorIndex, trans);
map.addToTable(bsprslt);
cnt++;
} else {
Log.severe("Texture mapping missing required parameters = line " + lineNum + " of " + txtname);
}
}
} else if (typeid.equals("copyblock")) {
// Parse block states
bsp.processLine(modname, line, lineNum, varvals);
String[] args = line.split(",");
String srcname = null;
int srcmeta = 0;
BlockTransparency trans = null;
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
if (av[0].equals("srcid")) {
srcname = getBlockName(modname, av[1]);
} else if (av[0].equals("srcmeta")) {
srcmeta = getIntValue(varvals, av[1]);
} else if (av[0].equals("transparency")) {
trans = BlockTransparency.valueOf(av[1]);
if (trans == null) {
trans = BlockTransparency.OPAQUE;
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + lineNum + " of " + txtname);
}
/* For leaves, base on leaf transparency setting */
if (trans == BlockTransparency.LEAVES) {
if (core.getLeafTransparency())
trans = BlockTransparency.TRANSPARENT;
else
trans = BlockTransparency.OPAQUE;
}
}
}
/* If we have everything, build block */
bsprslt = bsp.getMatchingStates();
if ((bsprslt.size() > 0) && (srcname != null)) {
DynmapBlockState srcblk = DynmapBlockState.getStateByNameAndIndex(srcname, srcmeta);
HDBlockStateTextureMap map = null;
if (srcblk != null)
map = HDBlockStateTextureMap.getByBlockState(srcblk);
if (map == null) {
Log.severe("Copy of texture mapping failed = line " + lineNum + " of " + txtname);
} else {
for (DynmapBlockState bblk : bsprslt.keySet()) {
BitSet stateids = bsprslt.get(bblk);
for (int stateid = stateids.nextSetBit(0); stateid >= 0; stateid = stateids.nextSetBit(stateid + 1)) {
DynmapBlockState dblk2 = bblk.getState(stateid);
HDBlockStateTextureMap.copyToStateIndex(dblk2, map, trans);
}
}
cnt++;
}
} else {
Log.severe("Texture mapping copy missing required parameters = line " + lineNum + " of " + txtname);
}
} else if (typeid.equals("addtotexturemap")) {
int srctxtid = -1;
String mapid = null;
String[] args = line.split(",");
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
else if (av[0].equals("txtid")) {
if (filetoidx.containsKey(av[1]))
srctxtid = filetoidx.get(av[1]);
else
Log.severe("Format error - line " + lineNum + " of " + txtname);
} else if (av[0].equals("mapid")) {
mapid = av[1];
}
}
if (mapid != null) {
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
if (av[0].startsWith("key:")) {
Integer key = getIntValue(varvals, av[0].substring(4));
if ((key != null) && (key > 0)) {
addTextureByKey(mapid, key, parseTextureIndex(filetoidx, srctxtid, av[1]));
}
}
}
} else {
Log.severe("Missing mapid - line " + lineNum + " of " + txtname);
}
} else if (typeid.equals("texturemap")) {
// Parse block states
bsp.processLine(modname, line, lineNum, varvals);
String mapid = null;
BlockTransparency trans = BlockTransparency.OPAQUE;
int colorMult = 0;
CustomColorMultiplier custColorMult = null;
String[] args = line.split(",");
for (String a : args) {
String[] av = a.split("=");
if (av.length < 2)
continue;
if (av[0].equals("mapid")) {
mapid = av[1];
} else if (av[0].equals("transparency")) {
trans = BlockTransparency.valueOf(av[1]);
if (trans == null) {
trans = BlockTransparency.OPAQUE;
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + lineNum + " of " + txtname);
}
/* For leaves, base on leaf transparency setting */
if (trans == BlockTransparency.LEAVES) {
if (core.getLeafTransparency())
trans = BlockTransparency.TRANSPARENT;
else
trans = BlockTransparency.OPAQUE;
}
} else if (av[0].equals("colorMult")) {
colorMult = Integer.valueOf(av[1], 16);
} else if (av[0].equals("custColorMult")) {
try {
Class<?> cls = Class.forName(av[1]);
custColorMult = (CustomColorMultiplier) cls.newInstance();
} catch (Exception x) {
Log.severe("Error loading custom color multiplier - " + av[1] + ": " + x.getMessage());
}
}
}
/* If we have everything, build texture map */
bsprslt = bsp.getMatchingStates();
if ((bsprslt.size() > 0) && (mapid != null)) {
addTextureIndex(mapid, bsprslt, trans, colorMult, custColorMult, blockset);
} else {
Log.severe("Texture map missing required parameters = line " + lineNum + " of " + txtname);
}
} else if (typeid.equals("texturefile") || typeid.equals("texture")) {
boolean istxt = typeid.equals("texture");
String[] args = line.split(",");
int xdim = 16, ydim = 16;
String fname = null;
String id = null;
TileFileFormat fmt = TileFileFormat.GRID;
MaterialType mt = null;
if (istxt) {
xdim = ydim = 1;
fmt = TileFileFormat.GRID;
}
for (String arg : args) {
String[] aval = arg.split("=");
if (aval.length < 2)
continue;
if (aval[0].equals("id")) {
id = aval[1];
if (fname == null) {
if (texturepath != null) {
fname = texturepath + id + ".png";
} else if (texturemod != null) {
fname = "mods/" + texturemod + "/textures/blocks/" + id + ".png";
}
}
} else if (aval[0].equals("filename"))
fname = aval[1];
else if (aval[0].equals("xcount"))
xdim = Integer.parseInt(aval[1]);
else if (aval[0].equals("ycount"))
ydim = Integer.parseInt(aval[1]);
else if (aval[0].equals("format")) {
fmt = TileFileFormat.valueOf(aval[1].toUpperCase());
if (fmt == null) {
Log.severe("Invalid format type " + aval[1] + " - line " + lineNum + " of " + txtname);
return;
}
} else if (aval[0].equals("material")) {
mt = MaterialType.valueOf(aval[1]);
if (mt == null) {
Log.warning("Bad custom material type: " + aval[1]);
}
}
}
if ((fname != null) && (id != null)) {
/* Register the file */
int fid = findOrAddDynamicTileFile(fname, modname, xdim, ydim, fmt, args);
filetoidx.put(id, fid);
/* Save lookup */
if (mt != null) {
addonfiles.get(fid).material = mt;
}
} else {
Log.severe("Format error - line " + lineNum + " of " + txtname);
return;
}
} else if (typeid.equals("enabled")) {
/* Test if texture file is enabled */
if (line.startsWith("true")) {
/* We're enabled? */
/* Nothing to do - keep processing */
} else if (line.startsWith("false")) {
/* Disabled */
return;
/* Quit */
} else /* If setting is not defined or false, quit */
if (config.getBoolean(line, false) == false) {
return;
} else {
Log.info(line + " textures enabled");
}
} else if (typeid.equals("var")) {
/* Test if variable declaration */
String[] args = line.split(",");
for (int i = 0; i < args.length; i++) {
String[] v = args[i].split("=");
if (v.length < 2) {
Log.severe("Format error - line " + lineNum + " of " + txtname);
return;
}
try {
int val = Integer.valueOf(v[1]);
/* Parse default value */
int parmval = config.getInteger(v[0], val);
/* Read value, with applied default */
varvals.put(v[0], parmval);
/* And save value */
} catch (NumberFormatException nfx) {
Log.severe("Format error - line " + lineNum + " of " + txtname + ": " + nfx.getMessage());
return;
}
}
} else if (typeid.equals("cfgfile")) {
/* If config file */
if (!mod_cfg_loaded) {
mod_cfg_needed = true;
}
File cfgfile = new File(line);
ForgeConfigFile cfg = new ForgeConfigFile(cfgfile);
if (cfg.load()) {
cfg.addBlockIDs(varvals);
mod_cfg_needed = false;
mod_cfg_loaded = true;
}
} else if (typeid.equals("modname")) {
String[] names = line.split(",");
boolean found = false;
for (String n : names) {
String[] ntok = n.split("[\\[\\]]");
String rng = null;
if (ntok.length > 1) {
n = ntok[0].trim();
rng = ntok[1].trim();
}
n = n.trim();
// If already supplied by mod, quit processing this file
if (loadedmods.contains(n)) {
return;
}
String modver = core.getServer().getModVersion(n);
if ((modver != null) && ((rng == null) || HDBlockModels.checkVersionRange(modver, rng))) {
found = true;
Log.info(n + "[" + modver + "] textures enabled");
modname = n;
modversion = modver;
if (texturemod == null)
texturemod = modname;
loadedmods.add(n);
// Prime values from block and item unique IDs
core.addModBlockItemIDs(modname, varvals);
break;
}
}
if (!found)
return;
} else if (typeid.equals("texturemod")) {
texturemod = line;
} else if (typeid.equals("texturepath")) {
texturepath = line.trim();
if (texturepath.charAt(texturepath.length() - 1) != '/') {
texturepath += "/";
}
} else if (typeid.equals("biome")) {
String[] args = line.split(",");
int id = 0;
int grasscolormult = -1;
int foliagecolormult = -1;
int watercolormult = -1;
double rain = -1.0;
double tmp = -1.0;
for (int i = 0; i < args.length; i++) {
String[] v = args[i].split("=");
if (v.length < 2) {
Log.severe("Format error - line " + lineNum + " of " + txtname);
return;
}
if (v[0].equals("id")) {
id = getIntValue(varvals, v[1]);
} else if (v[0].equals("grassColorMult")) {
grasscolormult = Integer.valueOf(v[1], 16);
} else if (v[0].equals("foliageColorMult")) {
foliagecolormult = Integer.valueOf(v[1], 16);
} else if (v[0].equals("waterColorMult")) {
watercolormult = Integer.valueOf(v[1], 16);
} else if (v[0].equals("temp")) {
tmp = Double.parseDouble(v[1]);
} else if (v[0].equals("rain")) {
rain = Double.parseDouble(v[1]);
}
}
if (id > 0) {
BiomeMap b = BiomeMap.byBiomeID(id);
/* Find biome */
if (b == null) {
Log.severe("Format error - line " + lineNum + " of " + txtname + ": " + id);
} else {
if (foliagecolormult != -1)
b.setFoliageColorMultiplier(foliagecolormult);
if (grasscolormult != -1)
b.setGrassColorMultiplier(grasscolormult);
if (watercolormult != -1)
b.setWaterColorMultiplier(watercolormult);
if (tmp != -1.0)
b.setTemperature(tmp);
if (rain != -1.0)
b.setRainfall(rain);
}
}
} else if (typeid.equals("version")) {
if (!HDBlockModels.checkVersionRange(mcver, line)) {
return;
}
} else if (typeid.equals("noterrainpng")) {
if (line.startsWith("true")) {
terrain_ok = false;
} else {
terrain_ok = true;
}
}
}
if (mod_cfg_needed) {
Log.severe("Error loading configuration file for " + modname);
}
Log.verboseinfo("Loaded " + cnt + " texture mappings from " + txtname);
} catch (IOException iox) {
Log.severe("Error reading " + txtname + " - " + iox.toString());
} catch (NumberFormatException nfx) {
Log.severe("Format error - line " + rdr.getLineNumber() + " of " + txtname + ": " + nfx.getMessage());
} finally {
if (rdr != null) {
try {
rdr.close();
rdr = null;
} catch (IOException e) {
}
}
}
}
use of org.dynmap.common.BiomeMap in project dynmap by webbukkit.
the class TexturePack method getCurrentBlockMaterials.
public String[] getCurrentBlockMaterials(DynmapBlockState blk, MapIterator mapiter, int[] txtidx, BlockStep[] steps) {
HDBlockStateTextureMap map = HDBlockStateTextureMap.getByBlockState(blk);
if (txtidx == null)
txtidx = deftxtidx;
// One for each face
String[] rslt = new String[txtidx.length];
boolean handlestdrot = (steps != null) && (!map.stdrotate);
Integer blockcoloring = this.blockColoring.getBlkStateValue(blk);
int custclrmult = -1;
// If block has custom coloring
if (blockcoloring != null) {
LoadedImage img = imgs[blockcoloring.intValue()];
if (img.argb != null) {
custclrmult = mapiter.getSmoothWaterColorMultiplier(img.argb);
} else {
blockcoloring = null;
}
}
for (int patchidx = 0; patchidx < txtidx.length; patchidx++) {
int faceindex = txtidx[patchidx];
int textid = map.faces[faceindex];
int mod = textid / COLORMOD_MULT_INTERNAL;
textid = textid % COLORMOD_MULT_INTERNAL;
BlockStep step = steps[patchidx];
/* If clear-inside op, get out early */
if ((mod == COLORMOD_CLEARINSIDE) || (mod == COLORMOD_MULTTONED_CLEARINSIDE)) {
BlockStep dir = step.opposite();
/* Check if previous block is same block type as we are: surface is transparent if it is */
if (blk.matchingBaseState(mapiter.getBlockTypeAt(dir))) {
// Skip: no texture
continue;
}
/* If water block, to watercolor tone op */
if (blk.isWater()) {
mod = COLORMOD_WATERTONED;
} else if (mod == COLORMOD_MULTTONED_CLEARINSIDE) {
mod = COLORMOD_MULTTONED;
}
}
if (ctm != null) {
textid = ctm.mapTexture(mapiter, blk, step, textid, null);
}
if (textid >= 0) {
// Default texture
rslt[patchidx] = getMatIDForTileID(textid);
int mult = 0xFFFFFF;
BiomeMap bio;
if (blockcoloring == null) {
switch(mod) {
case COLORMOD_GRASSTONED:
case COLORMOD_GRASSTONED270:
bio = mapiter.getBiome();
if ((bio == BiomeMap.SWAMPLAND) && (imgs[IMG_SWAMPGRASSCOLOR] != null)) {
mult = getBiomeTonedColor(imgs[IMG_SWAMPGRASSCOLOR], -1, bio, blk);
} else {
mult = getBiomeTonedColor(imgs[IMG_GRASSCOLOR], -1, bio, blk);
}
break;
case COLORMOD_FOLIAGETONED:
case COLORMOD_FOLIAGETONED270:
case COLORMOD_FOLIAGEMULTTONED:
mult = getBiomeTonedColor(imgs[IMG_FOLIAGECOLOR], -1, mapiter.getBiome(), blk);
break;
case COLORMOD_WATERTONED:
case COLORMOD_WATERTONED270:
mult = getBiomeTonedColor(imgs[IMG_WATERCOLORX], -1, mapiter.getBiome(), blk);
break;
case COLORMOD_PINETONED:
mult = getBiomeTonedColor(imgs[IMG_PINECOLOR], colorMultPine, mapiter.getBiome(), blk);
break;
case COLORMOD_BIRCHTONED:
mult = getBiomeTonedColor(imgs[IMG_BIRCHCOLOR], colorMultBirch, mapiter.getBiome(), blk);
break;
case COLORMOD_LILYTONED:
mult = getBiomeTonedColor(null, colorMultLily, mapiter.getBiome(), blk);
break;
case COLORMOD_MULTTONED:
case COLORMOD_MULTTONED_CLEARINSIDE:
if (map.custColorMult == null) {
mult = getBiomeTonedColor(null, map.colorMult, mapiter.getBiome(), blk);
} else {
mult = map.custColorMult.getColorMultiplier(mapiter);
}
break;
default:
mult = getBiomeTonedColor(null, -1, mapiter.getBiome(), blk);
break;
}
} else {
mult = custclrmult;
}
if ((mult & 0xFFFFFF) != 0xFFFFFF) {
rslt[patchidx] += String.format("__%06X", mult & 0xFFFFFF);
}
if (handlestdrot && (!map.stdrotate) && ((step == BlockStep.Y_MINUS) || (step == BlockStep.Y_PLUS))) {
// Handle rotations
switch(mod) {
case COLORMOD_ROT90:
mod = COLORMOD_ROT180;
break;
case COLORMOD_ROT180:
mod = COLORMOD_ROT270;
break;
case COLORMOD_ROT270:
case COLORMOD_GRASSTONED270:
case COLORMOD_FOLIAGETONED270:
case COLORMOD_WATERTONED270:
mod = 0;
break;
default:
mod = COLORMOD_ROT90;
break;
}
}
// Handle rotations
switch(mod) {
case COLORMOD_ROT90:
rslt[patchidx] += "@" + OBJExport.ROT90;
break;
case COLORMOD_ROT180:
rslt[patchidx] += "@" + OBJExport.ROT180;
break;
case COLORMOD_ROT270:
case COLORMOD_GRASSTONED270:
case COLORMOD_FOLIAGETONED270:
case COLORMOD_WATERTONED270:
rslt[patchidx] += "@" + +OBJExport.ROT270;
break;
case COLORMOD_FLIPHORIZ:
rslt[patchidx] += "@" + OBJExport.HFLIP;
break;
}
}
}
return rslt;
}
use of org.dynmap.common.BiomeMap in project dynmap by webbukkit.
the class DynmapPlugin method loadExtraBiomes.
public void loadExtraBiomes(String mcver) {
int cnt = 0;
BiomeMap.loadWellKnownByVersion(mcver);
Registry<Biome> biomeRegistry = getFabricServer().getBiomeRegistry();
Biome[] list = getFabricServer().getBiomeList(biomeRegistry);
for (int i = 0; i < list.length; i++) {
Biome bb = list[i];
if (bb != null) {
String id = biomeRegistry.getId(bb).getPath();
float tmp = bb.getTemperature(), hum = bb.getDownfall();
int watermult = ((BiomeEffectsAccessor) bb.getEffects()).getWaterColor();
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
BiomeMap bmap = BiomeMap.byBiomeID(i);
if (bmap.isDefault()) {
bmap = new BiomeMap(i, id, tmp, hum);
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
cnt++;
} else {
bmap.setTemperature(tmp);
bmap.setRainfall(hum);
}
if (watermult != -1) {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
}
}
if (cnt > 0)
Log.info("Added " + cnt + " custom biome mappings");
}
use of org.dynmap.common.BiomeMap in project dynmap by webbukkit.
the class DynmapPlugin method loadExtraBiomes.
public void loadExtraBiomes(String mcver) {
int cnt = 0;
BiomeMap.loadWellKnownByVersion(mcver);
Biome[] list = getBiomeList();
for (int i = 0; i < list.length; i++) {
Biome bb = list[i];
if (bb != null) {
String id = Registry.BIOME.getId(bb).getPath();
float tmp = bb.getTemperature(), hum = bb.getRainfall();
int watermult = bb.getWaterColor();
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
BiomeMap bmap = BiomeMap.byBiomeID(i);
if (bmap.isDefault()) {
bmap = new BiomeMap(i, id, tmp, hum);
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
cnt++;
} else {
bmap.setTemperature(tmp);
bmap.setRainfall(hum);
}
if (watermult != -1) {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
}
}
if (cnt > 0)
Log.info("Added " + cnt + " custom biome mappings");
}
use of org.dynmap.common.BiomeMap in project dynmap by webbukkit.
the class CTMTexturePack method mapTextureByProp.
private int mapTextureByProp(CTMProps p, Context ctx) {
// Test if right face
if ((ctx.laststep != null) && (p.faces != FACE_ALL)) {
int face = ctx.laststep.getFaceEntered();
// If not handled side
if ((p.faces & (1 << face)) == 0) {
return -1;
}
}
// Test if right metadata
if (p.metadata != -1) {
int meta = ctx.blk.stateIndex;
if ((p.metadata & (1 << meta)) == 0) {
return -1;
}
}
// Test if Y coordinate is valid
int y = ctx.mapiter.getY();
if ((y < p.minY) || (y > p.maxY)) {
return -1;
}
// Test if excluded
if (p.exclude(ctx.blk, ctx.laststep.getFaceEntered(), ctx)) {
return -1;
}
// Test if biome is valid
if (p.biomes != null) {
int ord = -1;
BiomeMap bio = ctx.mapiter.getBiome();
if (bio != null) {
ord = bio.getBiomeID();
}
for (int i = 0; i < p.biomes.length; i++) {
if (p.biomes[i] == ord) {
ord = -2;
break;
}
}
if (ord != -2) {
return -1;
}
}
// Rest of it is based on method
switch(p.method) {
case CTM:
return mapTextureCtm(p, ctx);
case HORIZONTAL:
return mapTextureHorizontal(p, ctx);
case TOP:
return mapTextureTop(p, ctx);
case RANDOM:
return mapTextureRandom(p, ctx);
case REPEAT:
return mapTextureRepeat(p, ctx);
case VERTICAL:
return mapTextureVertical(p, ctx);
case HORIZONTAL_VERTICAL:
return mapTextureHorizontalVertical(p, ctx);
case VERTICAL_HORIZONTAL:
return mapTextureVerticalHorizontal(p, ctx);
case FIXED:
return mapTextureFixed(p, ctx);
default:
return -1;
}
}
Aggregations