package org.egordorichev.lasttry.item;

import org.egordorichev.lasttry.LastTry;
import org.egordorichev.lasttry.util.Assets;
import org.egordorichev.lasttry.world.tile.TileData;
import org.newdawn.slick.Image;

public class Wall extends Item {
	public static final int DIRT_ID = 2;
	public static final Wall dirt = new Wall(Wall.DIRT_ID, "Dirt wall", Assets.dirtWallTexture);

	public Wall(int id, String name, Image texture) {
		super(id, name, Item.Type.WALL);

		this.texture = texture;
	}

	public void renderWall(TileData data, int x, int y) {
		boolean t = LastTry.world.getWallId(x, y - 1) == this.id;
		boolean r = LastTry.world.getWallId(x + 1, y) == this.id;
		boolean b = LastTry.world.getWallId(x, y + 1) == this.id;
		boolean l = LastTry.world.getWallId(x - 1, y) == this.id;

		this.texture.getSubImage(this.calculateBinary(t, r, b, l) * Block.TEX_SIZE, data.variant * Block.TEX_SIZE, Block.TEX_SIZE, Block.TEX_SIZE).draw(x * Block.TEX_SIZE, y * Block.TEX_SIZE);
	}


	private int calculateBinary(boolean top, boolean right, boolean bottom, boolean left) {
		int result = 0;

		if(top == true) {
			result += 1;
		}

		if(right == true) {
			result += 2;
		}

		if(bottom == true) {
			result += 4;
		}

		if(left == true) {
			result += 8;
		}

		return result;
	}

	public static Wall getForBlockId(int id) {
		switch(id) {
			case 0: return null;
			case 1: return Wall.dirt;
			default: return null;
		}
	}
	
	public static void preload() { }

}

@@ -242,46 +242,8 @@
 m %7B%0A
-%09public static final int DIRT_ID = 2;%0A
 %09pub
@@ -284,20 +284,23 @@
 all(
-Wall.DIRT_ID
+ItemID.dirtWall
 , %22D
@@ -1307,17 +1307,36 @@
 %09%09%09case 
-0
+ItemID.none: default
 : return
@@ -1350,17 +1350,32 @@
 %09%09%09case 
-1
+ItemID.dirtBlock
 : return
@@ -1390,33 +1390,8 @@
 rt;%0A
-%09%09%09default: return null;%0A
 %09%09%7D%0A

Update Wall.java