Prototype of chunk snapshot support - pre-Bukkit API (reflection
based, with fallback to existing APIs)
This commit is contained in:
parent
26f4f7d994
commit
3365a96565
11 changed files with 361 additions and 137 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package org.dynmap.kzedmap;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.MapChunkCache;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
|
||||
|
|
@ -11,14 +12,15 @@ public class CaveTileRenderer extends DefaultTileRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result) {
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result,
|
||||
MapChunkCache cache) {
|
||||
boolean air = true;
|
||||
result.setTransparent();
|
||||
for (;;) {
|
||||
if (y < 0)
|
||||
return;
|
||||
|
||||
int id = world.getBlockTypeIdAt(x, y, z);
|
||||
int id = cache.getBlockTypeID(x, y, z);
|
||||
if(isnether) { /* Make ceiling into air in nether */
|
||||
if(id != 0)
|
||||
id = 0;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.dynmap.ColorScheme;
|
|||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.MapChunkCache;
|
||||
|
||||
public class DefaultTileRenderer implements MapTileRenderer {
|
||||
protected static final Color translucent = new Color(0, 0, 0, 0);
|
||||
|
|
@ -44,7 +45,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
colorScheme = ColorScheme.getScheme((String)configuration.get("colorscheme"));
|
||||
}
|
||||
|
||||
public boolean render(KzedMapTile tile, File outputFile) {
|
||||
public boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile) {
|
||||
World world = tile.getWorld();
|
||||
boolean isnether = (world.getEnvironment() == Environment.NETHER);
|
||||
BufferedImage im = new BufferedImage(KzedMap.tileWidth, KzedMap.tileHeight, BufferedImage.TYPE_INT_RGB);
|
||||
|
|
@ -73,8 +74,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
jz = iz;
|
||||
|
||||
for (x = KzedMap.tileWidth - 1; x >= 0; x -= 2) {
|
||||
scan(world, jx, iy, jz, 0, isnether, c1);
|
||||
scan(world, jx, iy, jz, 2, isnether, c2);
|
||||
scan(world, jx, iy, jz, 0, isnether, c1, cache);
|
||||
scan(world, jx, iy, jz, 2, isnether, c2, cache);
|
||||
if(c1.isTransparent() == false) {
|
||||
rgb[0] = c1.getRed(); rgb[1] = c1.getGreen(); rgb[2] = c1.getBlue();
|
||||
r.setPixel(x, y, rgb);
|
||||
|
|
@ -97,10 +98,10 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
jz = iz - 1;
|
||||
|
||||
for (x = KzedMap.tileWidth - 1; x >= 0; x -= 2) {
|
||||
scan(world, jx, iy, jz, 2, isnether, c1);
|
||||
scan(world, jx, iy, jz, 2, isnether, c1, cache);
|
||||
jx++;
|
||||
jz++;
|
||||
scan(world, jx, iy, jz, 0, isnether, c2);
|
||||
scan(world, jx, iy, jz, 0, isnether, c2, cache);
|
||||
if(c1.isTransparent() == false) {
|
||||
rgb[0] = c1.getRed(); rgb[1] = c1.getGreen(); rgb[2] = c1.getBlue();
|
||||
r.setPixel(x, y, rgb);
|
||||
|
|
@ -210,13 +211,14 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
}
|
||||
|
||||
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result) {
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result,
|
||||
MapChunkCache cache) {
|
||||
result.setTransparent();
|
||||
for (;;) {
|
||||
if (y < 0) {
|
||||
return;
|
||||
}
|
||||
int id = world.getBlockTypeIdAt(x, y, z);
|
||||
int id = cache.getBlockTypeID(x, y, z);
|
||||
byte data = 0;
|
||||
if(isnether) { /* Make bedrock ceiling into air in nether */
|
||||
if(id != 0) {
|
||||
|
|
@ -230,7 +232,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
isnether = false;
|
||||
}
|
||||
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
||||
data = world.getBlockAt(x, y, z).getData();
|
||||
data = cache.getBlockData(x, y, z);
|
||||
}
|
||||
switch (seq) {
|
||||
case 0:
|
||||
|
|
@ -270,7 +272,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
}
|
||||
|
||||
/* this block is transparent, so recurse */
|
||||
scan(world, x, y, z, seq, isnether, result);
|
||||
scan(world, x, y, z, seq, isnether, result, cache);
|
||||
|
||||
int cr = c.getRed();
|
||||
int cg = c.getGreen();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.dynmap.kzedmap;
|
||||
|
||||
import java.util.HashSet;
|
||||
import org.dynmap.MapChunkCache;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
|
@ -19,14 +20,15 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result) {
|
||||
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result,
|
||||
MapChunkCache cache) {
|
||||
result.setTransparent();
|
||||
for (;;) {
|
||||
if (y < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
int id = world.getBlockTypeIdAt(x, y, z);
|
||||
int id = cache.getBlockTypeID(x, y, z);
|
||||
if(isnether) { /* Make bedrock ceiling into air in nether */
|
||||
if(id != 0) {
|
||||
/* Remember first color we see, in case we wind up solid */
|
||||
|
|
@ -40,7 +42,7 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
|
|||
}
|
||||
byte data = 0;
|
||||
if(colorScheme.datacolors[id] != null) { /* If data colored */
|
||||
data = world.getBlockAt(x, y, z).getData();
|
||||
data = cache.getBlockData(x, y, z);
|
||||
}
|
||||
|
||||
switch (seq) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.dynmap.DynmapChunk;
|
|||
import org.dynmap.Log;
|
||||
import org.dynmap.MapTile;
|
||||
import org.dynmap.MapType;
|
||||
import org.dynmap.MapChunkCache;
|
||||
|
||||
public class KzedMap extends MapType {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
|
@ -203,12 +204,12 @@ public class KzedMap extends MapType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean render(MapTile tile, File outputFile) {
|
||||
public boolean render(MapChunkCache cache, MapTile tile, File outputFile) {
|
||||
if (tile instanceof KzedZoomedMapTile) {
|
||||
zoomrenderer.render((KzedZoomedMapTile) tile, outputFile);
|
||||
zoomrenderer.render(cache, (KzedZoomedMapTile) tile, outputFile);
|
||||
return true;
|
||||
} else if (tile instanceof KzedMapTile) {
|
||||
return ((KzedMapTile) tile).renderer.render((KzedMapTile) tile, outputFile);
|
||||
return ((KzedMapTile) tile).renderer.render(cache, (KzedMapTile) tile, outputFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package org.dynmap.kzedmap;
|
||||
|
||||
import java.io.File;
|
||||
import org.dynmap.MapChunkCache;
|
||||
|
||||
public interface MapTileRenderer {
|
||||
String getName();
|
||||
|
||||
boolean render(KzedMapTile tile, File outputFile);
|
||||
boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package org.dynmap.kzedmap;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dynmap.MapChunkCache;
|
||||
public class ZoomedTileRenderer {
|
||||
public ZoomedTileRenderer(Map<String, Object> configuration) {
|
||||
}
|
||||
|
||||
public void render(final KzedZoomedMapTile zt, final File outputPath) {
|
||||
public void render(MapChunkCache cache, final KzedZoomedMapTile zt, final File outputPath) {
|
||||
return; /* Doing this in Default render, since image already loaded */
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue