package projectzombie.tiles;

import gl_engine.vec.Vec2i;
import projectzombie.init.Models;
import projectzombie.init.Tiles;
import projectzombie.model.Model;
import projectzombie.util.math.TileState;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class TileGrass extends Tile
{

	@Override
	public Model getModel(byte meta) {
		return Models.TILE_GRASS;
	}
	
	@Override
	public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
		super.tickRandomly(layer, chunk, state, pos);
		
		if(Math.random() > 0.95)
		{
			Vec2i cpos = pos.add(new Vec2i((int)Math.floor(Math.random() * 3) - 1, (int)Math.floor(Math.random() * 3) - 1));
			
			if(layer.getBackTile(cpos).tile == Tiles.DIRT) {
				layer.setBackTile(Tiles.GRASS.getDefaultState(), cpos);
			}
		}
	}

}
