package main.game.terrain;

import main.game.terrain.tile.Tile;
import main.game.terrain.tile.TileObject;
import main.graphics.textures.Sprite;

public class Tiles {
	
	private static Tile[] tiles = new Tile[512];

	public static Tile black = new Tile((short) 0, Sprite.black, false);
	public static Tile grass = new Tile((short) 1, Sprite.grass, false);
	public static Tile grassRock = new TileObject((short) 100, Sprite.grass, Sprite.rock2, true);
	public static Tile cornerBL = new TileObject((short) 106, Sprite.grass, Sprite.cornerBL, false);
	public static Tile cornerBR = new TileObject((short) 104, Sprite.grass, Sprite.cornerBR, false);
	public static Tile cornerTL = new TileObject((short) 108, Sprite.grass, Sprite.cornerTL, false);
	public static Tile cornerTR = new TileObject((short) 102, Sprite.grass, Sprite.cornerTR, false);
	public static Tile edgeL = new TileObject((short) 107, Sprite.grass, Sprite.edgeL, false);
	public static Tile edgeR = new TileObject((short) 103, Sprite.grass, Sprite.edgeR, false);
	public static Tile edgeT = new TileObject((short) 101, Sprite.grass, Sprite.edgeT, false);
	public static Tile edgeB = new TileObject((short) 105, Sprite.grass, Sprite.edgeB, false);
	
	public static Tile getTileFromId(short id) {
		return tiles[id];
	}

	public static void register(Tile tile) {
		tiles[tile.getId()] = tile;
	}

}

@@ -159,17 +159,16 @@
 Tiles %7B%0A
-%09
 %0A%09privat
@@ -416,25 +416,28 @@
 prite.grass,
- 
+%0A%09%09%09
 Sprite.rock2
@@ -509,33 +509,36 @@
 6, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.cornerBL,
@@ -610,33 +610,36 @@
 4, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.cornerBR,
@@ -711,33 +711,36 @@
 8, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.cornerTL,
@@ -816,25 +816,28 @@
 prite.grass,
- 
+%0A%09%09%09
 Sprite.corne
@@ -910,33 +910,36 @@
 7, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.edgeL, fa
@@ -1005,33 +1005,36 @@
 3, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.edgeR, fa
@@ -1100,33 +1100,36 @@
 1, Sprite.grass,
- 
+%0A%09%09%09
 Sprite.edgeT, fa
@@ -1203,17 +1203,20 @@
 e.grass,
- 
+%0A%09%09%09
 Sprite.e
@@ -1229,17 +1229,16 @@
 false);%0A
-%09
 %0A%09public
@@ -1282,23 +1282,76 @@
 %7B%0A%09%09
-return tiles%5Bid
+if (tiles%5Bid%5D != null)%0A%09%09%09return tiles%5Bid%5D;%0A%09%09else%0A%09%09%09return tiles%5B0
 %5D;%0A%09

Fix bug in Tiles