本文整理汇总了Java中com.protolambda.blocktopograph.chunk.ChunkManager类的典型用法代码示例。如果您正苦于以下问题:Java ChunkManager类的具体用法?Java ChunkManager怎么用?Java ChunkManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChunkManager类属于com.protolambda.blocktopograph.chunk包,在下文中一共展示了ChunkManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
int x, z, i, j, tX, tY;
int offsetX = chunkX * dimension.chunkW;
int offsetZ = chunkZ * dimension.chunkL;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setRGB(tX + j, tY + i, 0xff000000 | ((offsetX + x) ^ (offsetZ + z)));
}
}
}
}
return bm;
}
示例2: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
//System.out.println("chunkX:"+chunkX+", chunkZ:"+chunkZ+", bX:"+bX+", bZ:"+bZ+", eX:"+eX+", eZ:"+eZ+", pX:"+pX+", pY:"+pY+", pW:"+pW+", pL:"+pL);
int x, z, i, j, tX, tY;
int color;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
color = ((x + z) & 1) == 1 ? darkShade : lightShade;
for (i = 0; i < pL; i++) {
for (j = 0; j < pW; j++) {
bm.setRGB(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例3: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
int x, z, i, j, tX, tY;
int offsetX = chunkX * dimension.chunkW;
int offsetZ = chunkZ * dimension.chunkL;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setPixel(tX + j, tY + i, 0xff000000 | ((offsetX + x) ^ (offsetZ + z)));
}
}
}
}
return bm;
}
示例4: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
int x, z, i, j, tX, tY;
int color;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
color = ((x + z) & 1) == 1 ? darkShade : lightShade;
for (i = 0; i < pL; i++) {
for (j = 0; j < pW; j++) {
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例5: getChunkManager
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
public ChunkManager getChunkManager(Dimension d) {
switch (d) {
case OVERWORLD:
return cmOverworld;
case NETHER:
return cmNether;
case END:
return cmEnd;
default:
return cmOverworld;
}
}
示例6: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
int x, z, i, j, tX, tY;
MapType.OVERWORLD_SATELLITE.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
boolean isSlimeChunk = isSlimeChunk(chunkX, chunkZ);
int color, r, g, b, avg;
//make slimeChunks much more green
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
color = bm.getRGB(tX, tY);
r = (color >> 16) & 0xff;
g = (color >> 8) & 0xff;
b = color & 0xff;
avg = (r + g + b) / 3;
if(isSlimeChunk){
r = b = avg;
g = (g + 0xff) >> 1;
} else {
r = g = b = avg;
}
color = (color & 0xFF000000) | (r << 16) | (g << 8) | b;
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setRGB(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例7: removeMarker
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
public void removeMarker(AbstractMarker marker, boolean dirty){
long chunkKey = ChunkManager.xzToKey(marker.x >> 4, marker.z >> 4);
Set<AbstractMarker> chunk = chunks.get(chunkKey);
if(chunk != null) chunk.remove(marker);
//only set it to dirty if the marker is removed.
this.dirty |= markers.remove(marker) && dirty;
}
示例8: addMarker
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
public void addMarker(AbstractMarker marker, boolean dirty){
markers.add(marker);
long chunkKey = ChunkManager.xzToKey(marker.x >> 4, marker.z >> 4);
Set<AbstractMarker> chunk = chunks.get(chunkKey);
if(chunk == null) chunks.put(chunkKey, chunk = new HashSet<>());
chunk.add(marker);
this.dirty |= dirty;
}
示例9: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
int x, z, i, j, tX, tY;
MapType.OVERWORLD_SATELLITE.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
boolean isSlimeChunk = isSlimeChunk(chunkX, chunkZ);
int color, r, g, b, avg;
//make slimeChunks much more green
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
color = bm.getPixel(tX, tY);
r = (color >> 16) & 0xff;
g = (color >> 8) & 0xff;
b = color & 0xff;
avg = (r + g + b) / 3;
if(isSlimeChunk){
r = b = avg;
g = (g + 0xff) >> 1;
} else {
r = g = b = avg;
}
color = (color & 0xFF000000) | (r << 16) | (g << 8) | b;
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例10: WorldProvider
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
public WorldProvider(World world) {
this.world = world;
cmOverworld = new ChunkManager(world.getWorldData(), Dimension.OVERWORLD);
cmNether = new ChunkManager(world.getWorldData(), Dimension.NETHER);
cmEnd = new ChunkManager(world.getWorldData(), Dimension.END);
}
示例11: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
Chunk chunk = cm.getChunk(chunkX, chunkZ);
if(chunk == null) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
Version cVersion = chunk.getVersion();
if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
int x, y, z, subChunk, color, i, j, tX, tY;
//render width in blocks
int rW = eX - bX;
int[] light = new int[rW * (eZ - bZ)];
for(subChunk = 0; subChunk < cVersion.subChunks; subChunk++) {
TerrainChunkData data = chunk.getTerrain((byte) subChunk);
if (data == null || !data.loadTerrain()) break;
for (z = bZ; z < eZ; z++) {
for (x = bX; x < eX; x++) {
for (y = 0; y < cVersion.subChunkHeight; y++) {
light[(z * rW) + x] += data.getBlockLightValue(x, y, z) & 0xff;
}
}
}
}
int l;
for (z = bZ, tY = pY; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
l = light[(z * rW) + x];
l = l < 0 ? 0 : ((l > 0xff) ? 0xff : l);
color = (l << 16) | (l << 8) | (l) | 0xff000000;
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setRGB(tX + j, tY + i, color);
}
}
}
}
if(subChunk == 0) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
return bm;
}
示例12: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public BufferedImage renderToBitmap(ChunkManager cm, BufferedImage bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
Chunk chunk = cm.getChunk(chunkX, chunkZ);
if(chunk == null) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
Version cVersion = chunk.getVersion();
if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
//the bottom sub-chunk is sufficient to get heightmap data.
TerrainChunkData data = chunk.getTerrain((byte) 0);
if(data == null || !data.load2DData()) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
boolean west = true, north = true;
TerrainChunkData dataW = null, dataN = null;
Chunk dataWC = cm.getChunk(chunkX - 1, chunkZ);
if(dataWC != null)
dataW = dataWC.getTerrain((byte) 0);
else
west = false;
Chunk dataNC = cm.getChunk(chunkX, chunkZ-1);
if(dataNC != null)
dataN = dataNC.getTerrain((byte) 0);
else
north = false;
west &= dataW != null && dataW.load2DData();
north &= dataN != null && dataN.load2DData();
int x, y, z, color, i, j, tX, tY;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
y = data.getHeightMapValue(x, z);
color = getColumnColour(chunk, data, x, y, z,
(x == 0) ? (west ? dataW.getHeightMapValue(dimension.chunkW - 1, z) : y)//chunk edge
: data.getHeightMapValue(x - 1, z),//within chunk
(z == 0) ? (north ? dataN.getHeightMapValue(x, dimension.chunkL - 1) : y)//chunk edge
: data.getHeightMapValue(x, z - 1)//within chunk
);
//System.out.println(chunkX+" "+chunkZ);
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setRGB(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例13: getMarkersOfChunk
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
public Collection<AbstractMarker> getMarkersOfChunk(int chunkX, int chunkZ){
long key = ChunkManager.xzToKey(chunkX, chunkZ);
Set<AbstractMarker> chunk = chunks.get(key);
if(chunk == null) chunks.put(key, chunk = new HashSet<>());
return chunk;
}
示例14: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
Chunk chunk = cm.getChunk(chunkX, chunkZ);
Version cVersion = chunk.getVersion();
if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
if(cVersion == Version.NULL) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
int x, y, z, subChunk, color, i, j, tX, tY;
//render width in blocks
int rW = eX - bX;
int[] light = new int[rW * (eZ - bZ)];
for(subChunk = 0; subChunk < cVersion.subChunks; subChunk++) {
TerrainChunkData data = chunk.getTerrain((byte) subChunk);
if (data == null || !data.loadTerrain()) break;
for (z = bZ; z < eZ; z++) {
for (x = bX; x < eX; x++) {
for (y = 0; y < cVersion.subChunkHeight; y++) {
light[((z - bZ) * rW) + (x - bX)] += data.getBlockLightValue(x, y, z) & 0xff;
}
}
}
}
int l;
for (z = bZ, tY = pY; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
l = light[((z - bZ) * rW) + (x - bX)];
l = l < 0 ? 0 : ((l > 0xff) ? 0xff : l);
color = (l << 16) | (l << 8) | (l) | 0xff000000;
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
if(subChunk == 0) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
return bm;
}
示例15: renderToBitmap
import com.protolambda.blocktopograph.chunk.ChunkManager; //导入依赖的package包/类
/**
* Render a single chunk to provided bitmap (bm)
* @param cm ChunkManager, provides chunks, which provide chunk-data
* @param bm Bitmap to render to
* @param dimension Mapped dimension
* @param chunkX X chunk coordinate (x-block coord / Chunk.WIDTH)
* @param chunkZ Z chunk coordinate (z-block coord / Chunk.LENGTH)
* @param bX begin block X coordinate, relative to chunk edge
* @param bZ begin block Z coordinate, relative to chunk edge
* @param eX end block X coordinate, relative to chunk edge
* @param eZ end block Z coordinate, relative to chunk edge
* @param pX texture X pixel coord to start rendering to
* @param pY texture Y pixel coord to start rendering to
* @param pW width (X) of one block in pixels
* @param pL length (Z) of one block in pixels
* @return bm is returned back
*
* @throws Version.VersionException when the version of the chunk is unsupported.
*/
public Bitmap renderToBitmap(ChunkManager cm, Bitmap bm, Dimension dimension, int chunkX, int chunkZ, int bX, int bZ, int eX, int eZ, int pX, int pY, int pW, int pL) throws Version.VersionException {
Chunk chunk = cm.getChunk(chunkX, chunkZ);
Version cVersion = chunk.getVersion();
if(cVersion == Version.ERROR) return MapType.ERROR.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
if(cVersion == Version.NULL) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
//the bottom sub-chunk is sufficient to get heightmap data.
TerrainChunkData data = chunk.getTerrain((byte) 0);
if(data == null || !data.load2DData()) return MapType.CHESS.renderer.renderToBitmap(cm, bm, dimension, chunkX, chunkZ, bX, bZ, eX, eZ, pX, pY, pW, pL);
TerrainChunkData dataW = cm.getChunk(chunkX - 1, chunkZ).getTerrain((byte) 0);
TerrainChunkData dataN = cm.getChunk(chunkX, chunkZ-1).getTerrain((byte) 0);
boolean west = dataW != null && dataW.load2DData(),
north = dataN != null && dataN.load2DData();
int x, y, z, color, i, j, tX, tY;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
y = data.getHeightMapValue(x, z);
color = getColumnColour(chunk, data, x, y, z,
(x == 0) ? (west ? dataW.getHeightMapValue(dimension.chunkW - 1, z) : y)//chunk edge
: data.getHeightMapValue(x - 1, z),//within chunk
(z == 0) ? (north ? dataN.getHeightMapValue(x, dimension.chunkL - 1) : y)//chunk edge
: data.getHeightMapValue(x, z - 1)//within chunk
);
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
return bm;
}