本文整理汇总了Java中com.protolambda.blocktopograph.chunk.ChunkManager.getChunk方法的典型用法代码示例。如果您正苦于以下问题:Java ChunkManager.getChunk方法的具体用法?Java ChunkManager.getChunk怎么用?Java ChunkManager.getChunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.protolambda.blocktopograph.chunk.ChunkManager
的用法示例。
在下文中一共展示了ChunkManager.getChunk方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 {
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;
}
示例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 {
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;
}
示例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 {
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;
}
示例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 {
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;
}
示例5: 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 grass 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);
int x, 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) {
color = ((data.getGrassR(x, z) & 0xff) << 16) | ((data.getGrassG(x, z) & 0xff) << 8) | (data.getGrassB(x, z) & 0xff) | 0xff000000;
for (i = 0; i < pL; i++) {
for (j = 0; j < pW; j++) {
bm.setRGB(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例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 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 grass 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);
int x, 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) {
color = ((data.getGrassR(x, z) & 0xff) << 16) | ((data.getGrassG(x, z) & 0xff) << 8) | (data.getGrassB(x, z) & 0xff) | 0xff000000;
for (i = 0; i < pL; i++) {
for (j = 0; j < pW; j++) {
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
return bm;
}
示例7: 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 biome 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);
int x, z, biomeID, color, i, j, tX, tY;
Biome biome;
for (z = bZ, tY = pY ; z < eZ; z++, tY += pL) {
for (x = bX, tX = pX; x < eX; x++, tX += pW) {
biomeID = data.getBiome(x, z) & 0xff;
biome = Biome.getBiome(biomeID);
color = biome == null ? 0xff000000 : (biome.color.red << 16) | (biome.color.green << 8) | (biome.color.blue) | 0xff000000;
for(i = 0; i < pL; i++){
for(j = 0; j < pW; j++){
bm.setPixel(tX + j, tY + i, color);
}
}
}
}
return bm;
}