public void initDrawingArea() { if (!isValid) { return; } DrawingArea.initDrawingArea(height, width, pixels); }
public void initDrawingArea() { DrawingArea.initDrawingArea(height, width, pixels); }
public static Sprite getSprite(int itemId, int itemAmount, int type) { if (type == 0) { Sprite sprite = (Sprite)spriteCache.get(itemId); if (sprite != null && sprite.maxHeight != itemAmount && sprite.maxHeight != -1) { sprite.unlink(); sprite = null; } if (sprite != null) { return(sprite); } } ItemDefinition definition = getDefinition(itemId); if (definition.stackableIds == null) { itemAmount = -1; } if (itemAmount > 1) { int stackedId = -1; for (int amount = 0; amount < 10; amount++) { if (itemAmount >= definition.stackableAmounts[amount] && definition.stackableAmounts[amount] != 0) { stackedId = definition.stackableIds[amount]; } } if (stackedId != -1) { definition = getDefinition(stackedId); } } Model model = definition.getAmountModel(1); if (model == null) { return(null); } Sprite noteSprite = null; if (definition.noteTemplateId != -1) { noteSprite = getSprite(definition.noteId, 10, -1); if (noteSprite == null) { return(null); } } Sprite itemSprite = new Sprite(32, 32); int textureCentreX = Rasterizer.centreX; int textureCentreY = Rasterizer.centreY; int[] lineOffsets = Rasterizer.lineOffsets; int[] pixels = DrawingArea.pixels; int width = DrawingArea.width; int height = DrawingArea.height; int topX = DrawingArea.topX; int bottomX = DrawingArea.bottomX; int topY = DrawingArea.topY; int bottomY = DrawingArea.bottomY; Rasterizer.textured = false; DrawingArea.initDrawingArea(32, 32, itemSprite.pixels); DrawingArea.drawFilledRectangle(0, 0, 32, 32, 0); Rasterizer.setDefaultBounds(); int zoom = definition.modelZoom; if (type == -1) { zoom = (int)(zoom * 1.5D); } if (type > 0) { zoom = (int)(zoom * 1.04D); } int l3 = Rasterizer.SINE[definition.modelRotationX] * zoom >> 16; int i4 = Rasterizer.COSINE[definition.modelRotationX] * zoom >> 16; model.renderSingle(definition.modelRotationY, definition.modelRotationZ, definition.modelRotationX, definition.modelOffset1, l3 + model.modelHeight / 2 + definition.modelOffset2, i4 + definition.modelOffset2); for (int _x = 31; _x >= 0; _x--) { for (int _y = 31; _y >= 0; _y--) { if (itemSprite.pixels[_x + _y * 32] == 0) { if (_x > 0 && itemSprite.pixels[(_x - 1) + _y * 32] > 1) { itemSprite.pixels[_x + _y * 32] = 1; } else if (_y > 0 && itemSprite.pixels[_x + (_y - 1) * 32] > 1) { itemSprite.pixels[_x + _y * 32] = 1; } else if (_x < 31 && itemSprite.pixels[_x + 1 + _y * 32] > 1) { itemSprite.pixels[_x + _y * 32] = 1; } else if (_y < 31 && itemSprite.pixels[_x + (_y + 1) * 32] > 1) { itemSprite.pixels[_x + _y * 32] = 1; } } } } if (type > 0) { for (int _x = 31; _x >= 0; _x--) { for (int _y = 31; _y >= 0; _y--) { if (itemSprite.pixels[_x + _y * 32] == 0) { if (_x > 0 && itemSprite.pixels[(_x - 1) + _y * 32] == 1) { itemSprite.pixels[_x + _y * 32] = type; } else if (_y > 0 && itemSprite.pixels[_x + (_y - 1) * 32] == 1) { itemSprite.pixels[_x + _y * 32] = type; } else if (_x < 31 && itemSprite.pixels[_x + 1 + _y * 32] == 1) { itemSprite.pixels[_x + _y * 32] = type; } else if (_y < 31 && itemSprite.pixels[_x + (_y + 1) * 32] == 1) { itemSprite.pixels[_x + _y * 32] = type; } } } } } else if (type == 0) { for (int _x = 31; _x >= 0; _x--) { for (int _y = 31; _y >= 0; _y--) { if (itemSprite.pixels[_x + _y * 32] == 0 && _x > 0 && _y > 0 && itemSprite.pixels[(_x - 1) + (_y - 1) * 32] > 0) { itemSprite.pixels[_x + _y * 32] = 0x302020; } } } } if (definition.noteTemplateId != -1) { int _maxWidth = noteSprite.maxWidth; int _maxHeight = noteSprite.maxHeight; noteSprite.maxWidth = 32; noteSprite.maxHeight = 32; noteSprite.drawImage(0, 0); noteSprite.maxWidth = _maxWidth; noteSprite.maxHeight = _maxHeight; } if (type == 0) { spriteCache.put(itemSprite, itemId); } DrawingArea.initDrawingArea(height, width, pixels); DrawingArea.setDrawingArea(bottomY, topX, bottomX, topY); Rasterizer.centreX = textureCentreX; Rasterizer.centreY = textureCentreY; Rasterizer.lineOffsets = lineOffsets; Rasterizer.textured = true; if (definition.stackable) { itemSprite.maxWidth = 33; } else { itemSprite.maxWidth = 32; } itemSprite.maxHeight = itemAmount; return(itemSprite); }