mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Add 1.9 swamp biome shading, workaround chunk snapshot biome bug
This commit is contained in:
parent
336d4e7535
commit
9b0faa1325
@ -46,6 +46,7 @@ public class MapManager {
|
||||
private int parallelrendercnt = 0;
|
||||
private int progressinterval = 100;
|
||||
private boolean saverestorepending = true;
|
||||
private boolean swampshading = false;
|
||||
|
||||
private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */
|
||||
/* Which fullrenders are active */
|
||||
@ -503,6 +504,8 @@ public class MapManager {
|
||||
progressinterval = configuration.getInteger("progressloginterval", 100);
|
||||
if(progressinterval < 100) progressinterval = 100;
|
||||
saverestorepending = configuration.getBoolean("saverestorepending", true);
|
||||
/* Default swamp shading off for 1.8, on after */
|
||||
swampshading = configuration.getBoolean("swampshaded", !plugin.getServer().getVersion().contains("(MC: 1.8"));
|
||||
|
||||
this.tileQueue = new AsynchronousQueue<MapTile>(
|
||||
new Handler<MapTile>() {
|
||||
@ -999,4 +1002,8 @@ public class MapManager {
|
||||
sscache.resetStats();
|
||||
sender.sendMessage("Tile Render Statistics reset");
|
||||
}
|
||||
|
||||
public boolean getSwampShading() {
|
||||
return swampshading;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import java.util.zip.ZipFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.Log;
|
||||
@ -35,11 +36,11 @@ import org.dynmap.utils.MapIterator;
|
||||
* misc/water.png - still water tile (required))
|
||||
* misc/grasscolor.png - tone for grass color, biome sensitive (required)
|
||||
* misc/foliagecolor.png - tone for leaf color, biome sensitive (required)
|
||||
* misc/watercolor.png - tone for water color, biome sensitive (required)
|
||||
* custom_lava_still.png - custom still lava animation (optional)
|
||||
* custom_lava_flowing.png - custom flowing lava animation (optional)
|
||||
* custom_water_still.png - custom still water animation (optional)
|
||||
* custom_water_flowing.png - custom flowing water animation (optional)
|
||||
* BetterGlass/*.png - mod-based improved windows (future optional)
|
||||
*/
|
||||
public class TexturePack {
|
||||
/* Loaded texture packs */
|
||||
@ -48,6 +49,7 @@ public class TexturePack {
|
||||
private static final String TERRAIN_PNG = "terrain.png";
|
||||
private static final String GRASSCOLOR_PNG = "misc/grasscolor.png";
|
||||
private static final String FOLIAGECOLOR_PNG = "misc/foliagecolor.png";
|
||||
private static final String WATERCOLOR_PNG = "misc/watercolor.png";
|
||||
private static final String WATER_PNG = "misc/water.png";
|
||||
private static final String CUSTOMLAVASTILL_PNG = "custom_lava_still.png";
|
||||
private static final String CUSTOMLAVAFLOWING_PNG = "custom_lava_flowing.png";
|
||||
@ -59,7 +61,7 @@ public class TexturePack {
|
||||
private static final int COLORMOD_NONE = 0;
|
||||
private static final int COLORMOD_GRASSTONED = 1;
|
||||
private static final int COLORMOD_FOLIAGETONED = 2;
|
||||
private static final int COLORMOD_WATERTONED = 3; /* Not used */
|
||||
private static final int COLORMOD_WATERTONED = 3;
|
||||
private static final int COLORMOD_ROT90 = 4;
|
||||
private static final int COLORMOD_ROT180 = 5;
|
||||
private static final int COLORMOD_ROT270 = 6;
|
||||
@ -106,7 +108,8 @@ public class TexturePack {
|
||||
private static final int IMG_CUSTOMWATERSTILL = 4;
|
||||
private static final int IMG_CUSTOMLAVAMOVING = 5;
|
||||
private static final int IMG_CUSTOMLAVASTILL = 6;
|
||||
private static final int IMG_CNT = 7;
|
||||
private static final int IMG_WATERCOLOR = 7;
|
||||
private static final int IMG_CNT = 8;
|
||||
|
||||
private LoadedImage[] imgs = new LoadedImage[IMG_CNT];
|
||||
|
||||
@ -242,6 +245,18 @@ public class TexturePack {
|
||||
}
|
||||
loadBiomeShadingImage(is, IMG_FOLIAGECOLOR);
|
||||
is.close();
|
||||
/* Try to find and load misc/watercolor.png */
|
||||
ze = zf.getEntry(WATERCOLOR_PNG);
|
||||
if(ze == null) { /* Fall back to standard file */
|
||||
/* Check for misc/watercolor.png under standard texture pack*/
|
||||
File ff = new File(texturedir, STANDARDTP + "/" + WATERCOLOR_PNG);
|
||||
is = new FileInputStream(ff);
|
||||
}
|
||||
else {
|
||||
is = zf.getInputStream(ze);
|
||||
}
|
||||
loadBiomeShadingImage(is, IMG_WATERCOLOR);
|
||||
is.close();
|
||||
|
||||
/* Try to find and load misc/water.png */
|
||||
ze = zf.getEntry(WATER_PNG);
|
||||
@ -317,6 +332,14 @@ public class TexturePack {
|
||||
fis = new FileInputStream(f);
|
||||
loadBiomeShadingImage(fis, IMG_FOLIAGECOLOR);
|
||||
fis.close();
|
||||
/* Check for misc/watercolor.png */
|
||||
f = new File(texturedir, tpname + "/" + WATERCOLOR_PNG);
|
||||
if(!f.canRead()) {
|
||||
f = new File(texturedir, STANDARDTP + "/" + WATERCOLOR_PNG);
|
||||
}
|
||||
fis = new FileInputStream(f);
|
||||
loadBiomeShadingImage(fis, IMG_WATERCOLOR);
|
||||
fis.close();
|
||||
/* Check for misc/water.png */
|
||||
f = new File(texturedir, tpname + "/" + WATER_PNG);
|
||||
if(!f.canRead()) {
|
||||
@ -817,7 +840,8 @@ public class TexturePack {
|
||||
/**
|
||||
* Read color for given subblock coordinate, with given block id and data and face
|
||||
*/
|
||||
public final void readColor(final HDPerspectiveState ps, final MapIterator mapiter, final Color rslt, final int blkid, final int lastblocktype, final boolean biome_shaded) {
|
||||
public final void readColor(final HDPerspectiveState ps, final MapIterator mapiter, final Color rslt, final int blkid, final int lastblocktype,
|
||||
final boolean biome_shaded, final boolean swamp_shaded) {
|
||||
int blkdata = ps.getBlockData();
|
||||
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata, ps.getBlockRenderData());
|
||||
BlockStep laststep = ps.getLastBlockStep();
|
||||
@ -866,6 +890,10 @@ public class TexturePack {
|
||||
rslt.setTransparent();
|
||||
return;
|
||||
}
|
||||
/* If warer block, to watercolor tone op */
|
||||
if((blkid == 8) || (blkid == 9)) {
|
||||
textop = COLORMOD_WATERTONED;
|
||||
}
|
||||
}
|
||||
|
||||
int[] texture = terrain_argb[textid];
|
||||
@ -954,27 +982,30 @@ public class TexturePack {
|
||||
/* Read color from texture */
|
||||
rslt.setARGB(texture[v*native_scale + u]);
|
||||
|
||||
LoadedImage li;
|
||||
LoadedImage li = null;
|
||||
/* Switch based on texture modifier */
|
||||
switch(textop) {
|
||||
case COLORMOD_GRASSTONED:
|
||||
li = imgs[IMG_GRASSCOLOR];
|
||||
if((li.argb == null) || (!biome_shaded)) {
|
||||
rslt.blendColor(li.trivial_color);
|
||||
}
|
||||
else {
|
||||
rslt.blendColor(biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature()));
|
||||
}
|
||||
break;
|
||||
case COLORMOD_FOLIAGETONED:
|
||||
li = imgs[IMG_FOLIAGECOLOR];
|
||||
if((li.argb == null) || (!biome_shaded)) {
|
||||
rslt.blendColor(li.trivial_color);
|
||||
}
|
||||
else {
|
||||
rslt.blendColor(biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature()));
|
||||
}
|
||||
break;
|
||||
case COLORMOD_WATERTONED:
|
||||
li = imgs[IMG_WATERCOLOR];
|
||||
break;
|
||||
}
|
||||
if(li != null) {
|
||||
int clr;
|
||||
if((li.argb == null) || (!biome_shaded)) {
|
||||
clr = li.trivial_color;
|
||||
}
|
||||
else {
|
||||
clr = biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature());
|
||||
}
|
||||
if(swamp_shaded && (mapiter.getBiome() == Biome.SWAMPLAND))
|
||||
clr = (clr & 0xFF000000) | (((clr & 0x00FEFEFE) + 0x4E0E4E) / 2);
|
||||
rslt.blendColor(clr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.World.Environment;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.MapIterator;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -15,12 +16,14 @@ public class TexturePackHDShader implements HDShader {
|
||||
private String name;
|
||||
private TexturePack tp;
|
||||
private boolean biome_shaded;
|
||||
private boolean swamp_shaded;
|
||||
|
||||
public TexturePackHDShader(ConfigurationNode configuration) {
|
||||
tpname = configuration.getString("texturepack", "minecraft");
|
||||
name = configuration.getString("name", tpname);
|
||||
tp = TexturePack.getTexturePack(tpname);
|
||||
biome_shaded = configuration.getBoolean("biomeshaded", true);
|
||||
swamp_shaded = configuration.getBoolean("swampshaded", MapManager.mapman.getSwampShading());
|
||||
if(tp == null) {
|
||||
Log.severe("Error: shader '" + name + "' cannot load texture pack '" + tpname + "'");
|
||||
}
|
||||
@ -28,7 +31,7 @@ public class TexturePackHDShader implements HDShader {
|
||||
|
||||
@Override
|
||||
public boolean isBiomeDataNeeded() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,6 +74,7 @@ public class TexturePackHDShader implements HDShader {
|
||||
private HDLighting lighting;
|
||||
private int lastblkid;
|
||||
private boolean do_biome_shading;
|
||||
private boolean do_swamp_shading;
|
||||
|
||||
private OurShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache) {
|
||||
this.mapiter = mapiter;
|
||||
@ -88,6 +92,7 @@ public class TexturePackHDShader implements HDShader {
|
||||
scaledtp = tp.resampleTexturePack(map.getPerspective().getModelScale());
|
||||
/* Biome raw data only works on normal worlds at this point */
|
||||
do_biome_shading = biome_shaded && (cache.getWorld().getEnvironment() == Environment.NORMAL);
|
||||
do_swamp_shading = do_biome_shading && swamp_shaded;
|
||||
}
|
||||
/**
|
||||
* Get our shader
|
||||
@ -133,7 +138,7 @@ public class TexturePackHDShader implements HDShader {
|
||||
}
|
||||
|
||||
/* Get color from textures */
|
||||
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype, do_biome_shading);
|
||||
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype, do_biome_shading, do_swamp_shading);
|
||||
|
||||
if (c.getAlpha() > 0) {
|
||||
int subalpha = ps.getSubmodelAlpha();
|
||||
|
@ -43,7 +43,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
private boolean isempty = true;
|
||||
|
||||
private ChunkSnapshot[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
||||
|
||||
private Biome[][] biomess; /* Biome snapshots (workaround) - same index as snaparray */
|
||||
|
||||
private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS,
|
||||
BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS };
|
||||
|
||||
@ -95,7 +96,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
return snap.getBlockEmittedLight(bx, y, bz);
|
||||
}
|
||||
public Biome getBiome() {
|
||||
return snap.getBiome(bx, bz);
|
||||
return biomess[chunkindex][bx | (bz<<4)];
|
||||
}
|
||||
public double getRawBiomeTemperature() {
|
||||
return snap.getRawBiomeTemperature(bx, bz);
|
||||
@ -404,6 +405,14 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(biome) {
|
||||
Biome[] b = new Biome[256];
|
||||
for(int ii = 0; ii < 256; ii++) {
|
||||
b[ii] = w.getBiome((chunk.x<<4)+(ii & 0xF), (chunk.z<<4) + (ii >> 4));
|
||||
}
|
||||
if(biomess == null) biomess = new Biome[snaparray.length][];
|
||||
biomess[(chunk.x-x_min) + (chunk.z - z_min)*x_dim] = b;
|
||||
}
|
||||
/* Check if cached chunk snapshot found */
|
||||
ChunkSnapshot ss = MapManager.mapman.sscache.getSnapshot(w.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
|
||||
if(ss != null) {
|
||||
@ -498,6 +507,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
snaparray[i] = EMPTY;
|
||||
else if(snaparray[i] != EMPTY)
|
||||
isempty = false;
|
||||
if(biome && biomess[i] == null)
|
||||
biomess[i] = new Biome[256];
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
@ -561,8 +572,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
return ss.getBlockEmittedLight(x & 0xF, y, z & 0xF);
|
||||
}
|
||||
public Biome getBiome(int x, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return ss.getBiome(x & 0xF, z & 0xF);
|
||||
Biome[] b = biomess[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
return b[(x & 0xF) | ((z & 0xF)<<4)];
|
||||
}
|
||||
public double getRawBiomeTemperature(int x, int z) {
|
||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||
|
@ -3,7 +3,7 @@
|
||||
# <index>=0-255 (index of patch in terrain.png), -1=clear, 1xxx=biome tint from grasscolor.png,257=stationary water,258=moving water,
|
||||
# 259=stationary lava,260=moving lava,261=extended piston side,262=piston side while extended,263=glass pane top,2xxx=biome tint from foliagecolor.png,4xxx=rotate texture 90,
|
||||
# 5xxx=rotate texture 180, 6xxx=rotate texture 270, 7xxx=flip texture horizontally, 8xxx=shift down 1/2 block, 9=shift down 1/2,flip horiz,
|
||||
# 10xxx=inclined-torch,11xxx=grass-side,12xxx=clear if same block
|
||||
# 10xxx=inclined-torch,11xxx=grass-side,12xxx=clear if same block,3xxx=biome tint from watercolor.png
|
||||
######
|
||||
# Stone
|
||||
block:id=1,allfaces=1
|
||||
|
Loading…
Reference in New Issue
Block a user