当前位置: 首页>>代码示例>>Java>>正文


Java MapPalette.DARK_GRAY属性代码示例

本文整理汇总了Java中org.bukkit.map.MapPalette.DARK_GRAY属性的典型用法代码示例。如果您正苦于以下问题:Java MapPalette.DARK_GRAY属性的具体用法?Java MapPalette.DARK_GRAY怎么用?Java MapPalette.DARK_GRAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.map.MapPalette的用法示例。


在下文中一共展示了MapPalette.DARK_GRAY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawText

public void drawText(int x, int y, MapFont font, String text) {
    int xStart = x;
    byte color = MapPalette.DARK_GRAY;
    if (!font.isValid(text)) {
        throw new IllegalArgumentException("text contains invalid characters");
    }

    for (int i = 0; i < text.length(); ++i) {
        char ch = text.charAt(i);
        if (ch == '\n') {
            x = xStart;
            y += font.getHeight() + 1;
            continue;
        } else if (ch == '\u00A7') {
            int j = text.indexOf(';', i);
            if (j >= 0) {
                try {
                    color = Byte.parseByte(text.substring(i + 1, j));
                    i = j;
                    continue;
                }
                catch (NumberFormatException ex) {}
            }
        }

        CharacterSprite sprite = font.getChar(text.charAt(i));
        for (int r = 0; r < font.getHeight(); ++r) {
            for (int c = 0; c < sprite.getWidth(); ++c) {
                if (sprite.get(r, c)) {
                    setPixel(x + c, y + r, color);
                }
            }
        }
        x += sprite.getWidth() + 1;
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:36,代码来源:CraftMapCanvas.java

示例2: drawText

@SuppressWarnings("deprecation")
public void drawText(int x, int y, MapFont font, String text) {
    int xStart = x;
    byte color = MapPalette.DARK_GRAY;
    if (!font.isValid(text)) {
        throw new IllegalArgumentException("text contains invalid characters");
    }

    for (int i = 0; i < text.length(); ++i) {
        char ch = text.charAt(i);
        if (ch == '\n') {
            x = xStart;
            y += font.getHeight() + 1;
            continue;
        } else if (ch == '\u00A7') {
            int j = text.indexOf(';', i);
            if (j >= 0) {
                try {
                    color = Byte.parseByte(text.substring(i + 1, j));
                    i = j;
                    continue;
                }
                catch (NumberFormatException ex) {}
            }
        }

        CharacterSprite sprite = font.getChar(text.charAt(i));
        for (int r = 0; r < font.getHeight(); ++r) {
            for (int c = 0; c < sprite.getWidth(); ++c) {
                if (sprite.get(r, c)) {
                    setPixel(x + c, y + r, color);
                }
            }
        }
        x += sprite.getWidth() + 1;
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:37,代码来源:BufferedMapCanvas.java

示例3: render

/**
 * Renders the given ChunkInfoRenderingRequest.
 * 
 * @param request
 *            The request to render.
 */
private void render(ChunkInfoRenderingRequest request) {
    byte[][] destImage = request.getData();
    int minX = (request.getCenterX() >> 4) - 64;
    int minZ = (request.getCenterZ() >> 4) - 64;
    int maxX = minX + 128;
    int maxZ = minZ + 128;

    long started = System.currentTimeMillis();
    ChunkInfo[] chunkInfos = plugin.getChunkInfosInRange(
            request.getWorldName(), minX, minZ, maxX, maxZ);
    for (ChunkInfo info : chunkInfos) {
        final int localZ = info.getZ() - minZ;
        final int localX = info.getX() - minX;

        destImage[localZ][localX] = MapPalette.LIGHT_GRAY;
        if (info.getBreakedBlocks().size() > 0)
            destImage[localZ][localX] = MapPalette.DARK_GRAY;
        if (info.getPlacedBlocks().size() > 0)
            destImage[localZ][localX] = MapPalette.RED;
    }

    plugin.getLogger().info(
            String.format("Rendered %d chunks in %dms", chunkInfos.length,
                    System.currentTimeMillis() - started));
    request.setDone(true);
}
 
开发者ID:hapm,项目名称:swu,代码行数:32,代码来源:ChunkInfoRenderingTask.java

示例4: drawTextOld

public static void drawTextOld(MapCanvas canvas, int x, int y, int width, int height, MapFont font, String text)
{
	int xStart = x;
	byte color = MapPalette.DARK_GRAY;
/*	String text = "";
	
	for(char c : rawText.toCharArray())
		if(MinecraftFont.Font.getChar(c) != null)
			text += c;*/
	
	if(!MinecraftFont.Font.isValid(text))
		return;
	
	for (int i = 0; i < text.length(); ++i)
	{
		char ch = text.charAt(i);
		if (ch == '\n')
		{
			x = xStart;
			y += font.getHeight() + 1;
			continue;
		}
		else
			if (ch == '§')
			{
				int j = text.indexOf(';', i);
				if (j >= 0)
					try
					{
						color = Byte.parseByte(text.substring(i + 1, j));
						i = j;
						continue;
					}
					catch (NumberFormatException ex)
					{
					}
			}
		CharacterSprite sprite = font.getChar(text.charAt(i));
		for(int r = 0; r < font.getHeight(); ++r)
			for(int c = 0; c < sprite.getWidth(); ++c)
				for(int xx = 0; xx < width; xx++)
					for(int yy = 0; yy < height; yy++)
						if(sprite.get(r, c))
							canvas.setPixel(x + xx + c * width, y + yy + r * height, color);
		x += (sprite.getWidth() + 1) * width;
	}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:47,代码来源:BPMapRenderer.java


注:本文中的org.bukkit.map.MapPalette.DARK_GRAY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。