package common.block;

public enum Material {
	NONE {{
		this.setNonSolid().setReplaceable();
	}},
	LOOSE {{
		;
	}},
	WOOD {{
		this.setBurning();
	}},
	SOLID {{
		this.setRequiresTool();
	}},
	DIGGABLE {{ // can harvest with shovel
		this.setRequiresTool();
	}},
	TRANSLUCENT {{
		this.setTranslucent();
	}},
	BURNABLE {{
		this.setBurning();
	}},
	SOFT {{ // can break faster with sword, can't connect to fences+walls
		this.setNoPushMobility();
	}},
	PISTON {{
		this.setImmovableMobility();
	}},
	HEAVY {{
		this.setRequiresTool().setImmovableMobility();
	}},
	PLANT {{ // can break faster with sword
		this.setNonSolid().setNoPushMobility();
	}},
	SMALL {{ // can be placed more easily
		this.setNonSolid().setNoPushMobility();
	}},
	FLEECE {{
		this.setNonSolid().setBurning();
	}},
	EXPLOSIVE {{
		this.setBurning().setTranslucent();
	}},
	BLOCKING {{ // can't be placed next to signs and banners
		this.setTranslucent().setNoPushMobility();
	}},
	PORTAL {{ // not floodable by liquids
		this.setNonSolid().setImmovableMobility();
	}},
	WATER {{
		this.setLiquid(false).setReplaceable().setNoPushMobility();
	}},
	COLD {{
		this.setLiquid(false).setReplaceable().setNoPushMobility();
	}},
	LAVA {{
		this.setLiquid(true).setReplaceable().setNoPushMobility();
	}},
	HOT {{
		this.setLiquid(true).setReplaceable().setNoPushMobility();
	}},
	LEAVES {{ // can break faster with sword, precipitation block, special treatment in some worldgen
		this.setBurning().setTranslucent().setNoPushMobility();
	}},
	BUSH {{ // can break faster with sword, can be replaced by small tree leaves
		this.setNonSolid().setBurning().setNoPushMobility().setReplaceable();
	}},
	FIRE {{
		this.setNonSolid().setReplaceable().setNoPushMobility();
	}},
	POWDER {{ // can harvest with shovel, precipitation block
		this.setNonSolid().setReplaceable().setRequiresTool().setNoPushMobility();
	}},
	FLUFF {{ // can harvest with shears
		this.setPassable().setRequiresTool().setNoPushMobility();
	}};

	private boolean solid = true;
	private boolean lightOpaque = true;
	private boolean unpassable = true;
	private boolean opaque = true;
	private boolean liquid;
	private boolean cold;
	private boolean hot;
	private boolean burnable;
	private boolean replaceable;
	private boolean requiresTool;
	// 0 - normal; 1 - can't push other blocks; 2 - can't be pushed
	private int mobility;

	protected Material setTranslucent() {
		this.opaque = false;
		return this;
	}

	protected Material setNonSolid() {
		this.solid = false;
		this.lightOpaque = false;
		this.unpassable = false;
		this.opaque = false;
		return this;
	}

	protected Material setPassable() {
		this.unpassable = false;
		this.opaque = false;
		return this;
	}

	protected Material setLiquid(boolean hot) {
		this.solid = false;
		this.unpassable = false;
		this.opaque = false;
		this.liquid = true;
		if(hot)
			this.hot = true;
		else
			this.cold = true;
		return this;
	}

	protected Material setRequiresTool() {
		this.requiresTool = true;
		return this;
	}

	protected Material setBurning() {
		this.burnable = true;
		return this;
	}

	protected Material setReplaceable() {
		this.replaceable = true;
		return this;
	}

	protected Material setNoPushMobility() {
		this.mobility = 1;
		return this;
	}

	protected Material setImmovableMobility() {
		this.mobility = 2;
		return this;
	}

	public boolean isLiquid() {
		return this.liquid;
	}

	public boolean isColdLiquid() {
		return this.cold;
	}

	public boolean isHotLiquid() {
		return this.hot;
	}

	public boolean isSolid() {
		return this.solid;
	}

	public boolean blocksLight() {
		return this.lightOpaque;
	}

	public boolean blocksMovement() {
		return this.unpassable;
	}

	public boolean getCanBurn() {
		return this.burnable;
	}

	public boolean isReplaceable() {
		return this.replaceable;
	}

	public boolean isOpaque() {
		return this.opaque;
	}

	public boolean isToolRequired() {
		return this.requiresTool;
	}

	public int getMobility() {
		return this.mobility;
	}
}
