v0.29.1 - Made render improvements default on only for fresh installs: add 'correct-water-lighting', 'correct-biome-shading', 'use-generated-textures' settings to allow enable on existing installs

This commit is contained in:
Mike Primm 2012-01-09 12:27:22 +08:00 committed by mikeprimm
parent a172074efc
commit 478542418c
5 changed files with 130 additions and 18 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId> <groupId>org.dynmap</groupId>
<artifactId>dynmap</artifactId> <artifactId>dynmap</artifactId>
<version>0.30</version> <version>0.29.1</version>
<name>dynmap</name> <name>dynmap</name>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -91,6 +91,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
boolean waterbiomeshading = false; boolean waterbiomeshading = false;
boolean fencejoin = false; boolean fencejoin = false;
boolean bettergrass = false; boolean bettergrass = false;
boolean usegeneratedtextures = false;
boolean waterlightingfix = false;
boolean biomeshadingfix = false;
public CompassMode compassmode = CompassMode.PRE19; public CompassMode compassmode = CompassMode.PRE19;
private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */ private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */
private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */ private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */
@ -255,6 +260,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
bukkitConfiguration.load(); bukkitConfiguration.load();
configuration = new ConfigurationNode(bukkitConfiguration); configuration = new ConfigurationNode(bukkitConfiguration);
/* Add options to avoid 0.29 re-render (fixes very inconsistent with previous maps) */
usegeneratedtextures = configuration.getBoolean("use-generated-textures", false);
waterlightingfix = configuration.getBoolean("correct-water-lighting", false);
biomeshadingfix = configuration.getBoolean("correct-biome-shading", false);
/* Load block models */ /* Load block models */
HDBlockModels.loadModels(dataDirectory, configuration); HDBlockModels.loadModels(dataDirectory, configuration);
/* Load texture mappings */ /* Load texture mappings */
@ -282,6 +292,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
waterbiomeshading = configuration.getBoolean("waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8")); waterbiomeshading = configuration.getBoolean("waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8"));
/* Default fence-to-block-join off for 1.8, on after */ /* Default fence-to-block-join off for 1.8, on after */
fencejoin = configuration.getBoolean("fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8")); fencejoin = configuration.getBoolean("fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8"));
/* Default compassmode to pre19, to newrose after */ /* Default compassmode to pre19, to newrose after */
String cmode = configuration.getString("compass-mode", getServer().getVersion().contains("(MC: 1.8")?"pre19":"newrose"); String cmode = configuration.getString("compass-mode", getServer().getVersion().contains("(MC: 1.8")?"pre19":"newrose");
if(cmode.equals("newnorth")) if(cmode.equals("newnorth"))
@ -1894,4 +1905,15 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
private DynmapLocation toLoc(Location l) { private DynmapLocation toLoc(Location l) {
return new DynmapLocation(l.getWorld().getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ()); return new DynmapLocation(l.getWorld().getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ());
} }
public boolean useGeneratedTextures() {
return usegeneratedtextures;
}
public boolean waterLightingFix() {
return waterlightingfix;
}
public boolean biomeShadingFix() {
return biomeshadingfix;
}
} }

View File

@ -21,9 +21,17 @@ public class HDMapManager {
public HashSet<HDMap> maps = new HashSet<HDMap>(); public HashSet<HDMap> maps = new HashSet<HDMap>();
public HashMap<String, ArrayList<HDMap>> maps_by_world_perspective = new HashMap<String, ArrayList<HDMap>>(); public HashMap<String, ArrayList<HDMap>> maps_by_world_perspective = new HashMap<String, ArrayList<HDMap>>();
public static boolean usegeneratedtextures;
public static boolean waterlightingfix;
public static boolean biomeshadingfix;
public void loadHDShaders(DynmapPlugin plugin) { public void loadHDShaders(DynmapPlugin plugin) {
Log.verboseinfo("Loading shaders..."); Log.verboseinfo("Loading shaders...");
usegeneratedtextures = plugin.useGeneratedTextures();
waterlightingfix = plugin.waterLightingFix();
biomeshadingfix = plugin.biomeShadingFix();
File f = new File(plugin.getDataFolder(), "shaders.txt"); File f = new File(plugin.getDataFolder(), "shaders.txt");
if(!plugin.updateUsingDefaultResource("/shaders.txt", f, "shaders")) { if(!plugin.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
return; return;

View File

@ -75,6 +75,7 @@ public class TexturePack {
private static final int COLORMOD_PINETONED = 13; private static final int COLORMOD_PINETONED = 13;
private static final int COLORMOD_BIRCHTONED = 14; private static final int COLORMOD_BIRCHTONED = 14;
private static final int COLORMOD_LILYTONED = 15; private static final int COLORMOD_LILYTONED = 15;
private static final int COLORMOD_OLD_WATERSHADED = 16;
/* Special tile index values */ /* Special tile index values */
private static final int BLOCKINDEX_BLANK = -1; private static final int BLOCKINDEX_BLANK = -1;
@ -120,6 +121,8 @@ public class TexturePack {
private int terrain_width, terrain_height; private int terrain_width, terrain_height;
private int native_scale; private int native_scale;
private int water_toned_op = COLORMOD_WATERTONED;
private static final int IMG_GRASSCOLOR = 0; private static final int IMG_GRASSCOLOR = 0;
private static final int IMG_FOLIAGECOLOR = 1; private static final int IMG_FOLIAGECOLOR = 1;
private static final int IMG_WATER = 2; private static final int IMG_WATER = 2;
@ -173,6 +176,7 @@ public class TexturePack {
for(int i = 0; i < texmaps.length; i++) { for(int i = 0; i < texmaps.length; i++) {
texmaps[i] = this; texmaps[i] = this;
} }
} }
public HDTextureMap(List<Integer> blockids, int databits, int[] faces, BlockTransparency trans, boolean userender) { public HDTextureMap(List<Integer> blockids, int databits, int[] faces, BlockTransparency trans, boolean userender) {
@ -234,15 +238,20 @@ public class TexturePack {
private TexturePack(String tpname) throws FileNotFoundException { private TexturePack(String tpname) throws FileNotFoundException {
ZipFile zf = null; ZipFile zf = null;
File texturedir = getTexturePackDirectory(); File texturedir = getTexturePackDirectory();
boolean use_generate = HDMapManager.usegeneratedtextures;
if(HDMapManager.biomeshadingfix == false)
water_toned_op = COLORMOD_OLD_WATERSHADED;
/* Set up for enough files */ /* Set up for enough files */
imgs = new LoadedImage[IMG_CNT + addonfiles.size()]; imgs = new LoadedImage[IMG_CNT + addonfiles.size()];
/* Generate still and flowing water defaults */ /* Generate still and flowing water defaults */
generateWater(); if(use_generate) {
generateWaterFlowing(); generateWater();
generateLava(); generateWaterFlowing();
generateLavaFlow(); generateLava();
generateLavaFlow();
}
generateFire(); generateFire();
File f = new File(texturedir, tpname); File f = new File(texturedir, tpname);
@ -262,11 +271,27 @@ public class TexturePack {
} }
loadTerrainPNG(is); loadTerrainPNG(is);
is.close(); is.close();
/* Patch in generated defaults */ /* If not generating water, load it */
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER); if(!use_generate) {
patchTextureWithImage(IMG_WATERMOVING, BLOCKINDEX_MOVINGWATER); ze = zf.getEntry(WATER_PNG);
patchTextureWithImage(IMG_LAVA, BLOCKINDEX_STATIONARYLAVA); if(ze == null) {
patchTextureWithImage(IMG_LAVAMOVING, BLOCKINDEX_MOVINGLAVA); File ff = new File(texturedir, STANDARDTP + "/" + WATER_PNG);
is = new FileInputStream(ff);
}
else {
is = zf.getInputStream(ze);
}
loadImage(is, IMG_WATER);
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER);
patchTextureWithImage(IMG_WATER, BLOCKINDEX_MOVINGWATER);
is.close();
}
else {
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER);
patchTextureWithImage(IMG_WATERMOVING, BLOCKINDEX_MOVINGWATER);
patchTextureWithImage(IMG_LAVA, BLOCKINDEX_STATIONARYLAVA);
patchTextureWithImage(IMG_LAVAMOVING, BLOCKINDEX_MOVINGLAVA);
}
patchTextureWithImage(IMG_FIRE, BLOCKINDEX_FIRE); patchTextureWithImage(IMG_FIRE, BLOCKINDEX_FIRE);
/* Try to find and load misc/grasscolor.png */ /* Try to find and load misc/grasscolor.png */
@ -365,12 +390,26 @@ public class TexturePack {
fis = new FileInputStream(f); fis = new FileInputStream(f);
loadTerrainPNG(fis); loadTerrainPNG(fis);
fis.close(); fis.close();
/* Patch in generated defaults */ if(use_generate == false) { /* Not using generated - load water */
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER); /* Check for misc/water.png */
patchTextureWithImage(IMG_WATERMOVING, BLOCKINDEX_MOVINGWATER); f = new File(texturedir, tpname + "/" + WATER_PNG);
patchTextureWithImage(IMG_LAVA, BLOCKINDEX_STATIONARYLAVA); if(!f.canRead()) {
patchTextureWithImage(IMG_LAVAMOVING, BLOCKINDEX_MOVINGLAVA); f = new File(texturedir, STANDARDTP + "/" + WATER_PNG);
}
fis = new FileInputStream(f);
loadImage(fis, IMG_WATER);
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER);
patchTextureWithImage(IMG_WATER, BLOCKINDEX_MOVINGWATER);
fis.close();
}
else {
patchTextureWithImage(IMG_WATER, BLOCKINDEX_STATIONARYWATER);
patchTextureWithImage(IMG_WATERMOVING, BLOCKINDEX_MOVINGWATER);
patchTextureWithImage(IMG_LAVA, BLOCKINDEX_STATIONARYLAVA);
patchTextureWithImage(IMG_LAVAMOVING, BLOCKINDEX_MOVINGLAVA);
}
/* Patch in generated value */
patchTextureWithImage(IMG_FIRE, BLOCKINDEX_FIRE); patchTextureWithImage(IMG_FIRE, BLOCKINDEX_FIRE);
/* Check for misc/grasscolor.png */ /* Check for misc/grasscolor.png */
@ -454,6 +493,7 @@ public class TexturePack {
this.terrain_width = tp.terrain_width; this.terrain_width = tp.terrain_width;
this.terrain_height = tp.terrain_height; this.terrain_height = tp.terrain_height;
this.native_scale = tp.native_scale; this.native_scale = tp.native_scale;
this.water_toned_op = tp.water_toned_op;
this.imgs = tp.imgs; this.imgs = tp.imgs;
} }
@ -833,6 +873,27 @@ public class TexturePack {
} }
} }
/**
* Translate face ID - in case we've got options to fix it
*/
private static int translateFaceID(int id) {
int f = (id / 1000);
switch(f) {
case COLORMOD_PINETONED:
case COLORMOD_BIRCHTONED:
case COLORMOD_LILYTONED:
if(HDMapManager.biomeshadingfix == false) {
id = (COLORMOD_FOLIAGETONED * 1000) + (id % 1000);
}
break;
case COLORMOD_WATERTONED:
if(HDMapManager.biomeshadingfix == false) {
id = (COLORMOD_OLD_WATERSHADED * 1000) + (id % 1000);
}
break;
}
return id;
}
/** /**
* Load texture pack mappings from texture.txt file * Load texture pack mappings from texture.txt file
*/ */
@ -909,6 +970,10 @@ public class TexturePack {
trans = BlockTransparency.OPAQUE; trans = BlockTransparency.OPAQUE;
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + rdr.getLineNumber() + " of " + txtname); Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + rdr.getLineNumber() + " of " + txtname);
} }
/* If no water lighting fix */
if((blkids.contains(8) || blkids.contains(9)) && (HDMapManager.waterlightingfix == false)) {
trans = BlockTransparency.TRANSPARENT; /* Treat water as transparent if no fix */
}
} }
else if(av[0].equals("userenderdata")) { else if(av[0].equals("userenderdata")) {
userenderdata = av[1].equals("true"); userenderdata = av[1].equals("true");
@ -934,6 +999,8 @@ public class TexturePack {
if(databits < 0) databits = 0xFFFF; if(databits < 0) databits = 0xFFFF;
/* If we have everything, build block */ /* If we have everything, build block */
if(blkids.size() > 0) { if(blkids.size() > 0) {
for(int i = 0; i < faces.length; i++)
faces[i] = translateFaceID(faces[i]);
HDTextureMap map = new HDTextureMap(blkids, databits, faces, trans, userenderdata); HDTextureMap map = new HDTextureMap(blkids, databits, faces, trans, userenderdata);
map.addToTable(); map.addToTable();
cnt++; cnt++;
@ -1023,6 +1090,7 @@ public class TexturePack {
} }
} }
} }
} }
/* Process any ore hiding mappings */ /* Process any ore hiding mappings */
@ -1095,7 +1163,7 @@ public class TexturePack {
} }
/* If water block, to watercolor tone op */ /* If water block, to watercolor tone op */
if((blkid == 8) || (blkid == 9)) { if((blkid == 8) || (blkid == 9)) {
textop = COLORMOD_WATERTONED; textop = water_toned_op;
} }
} }
@ -1225,6 +1293,8 @@ public class TexturePack {
break; break;
} }
break; break;
case COLORMOD_OLD_WATERSHADED:
break;
} }
/* Read color from texture */ /* Read color from texture */
rslt.setARGB(texture[v*native_scale + u]); rslt.setARGB(texture[v*native_scale + u]);
@ -1252,6 +1322,10 @@ public class TexturePack {
case COLORMOD_LILYTONED: case COLORMOD_LILYTONED:
clrmult = 0xFF208030; /* from BlockLilyPad.java in MCP */ clrmult = 0xFF208030; /* from BlockLilyPad.java in MCP */
break; break;
case COLORMOD_OLD_WATERSHADED: /* Legacy water shading (wrong, but folks used it */
if(ss.do_water_shading)
li = imgs[IMG_WATERCOLOR];
break;
} }
if(li != null) { if(li != null) {
if((li.argb == null) || (!ss.do_biome_shading)) { if((li.argb == null) || (!ss.do_biome_shading)) {

View File

@ -188,6 +188,14 @@ enabletilehash: true
# Optional - enabled BetterGrass style rendering of grass and snow block sides # Optional - enabled BetterGrass style rendering of grass and snow block sides
#better-grass: true #better-grass: true
# Pre 0.29 render options - set all three to false if you want same results as 0.28 (i.e. you have existing maps and don't want to render)
# use-generated-textures: if true, use generated textures (same as client); false is static, pre 0.29 textures
# correct-water-lighting: if true, use corrected water lighting (same as client); false is legacy, pre 0.29 water (darker)
# correct-biome-shading: if true, use fixed color mappings for birch, pine, lily, and proper water shading (same as client); false is pre 0.29
use-generated-textures: true
correct-water-lighting: true
correct-biome-shading: true
# Control loading of player faces (if set to false, skins are never fetched) # Control loading of player faces (if set to false, skins are never fetched)
#fetchskins: false #fetchskins: false