/*
 * Copyright 2014 Matthew Collins
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.co.thinkofdeath.mapviewer.shared.block.blocks;

import uk.co.thinkofdeath.mapviewer.shared.block.Block;
import uk.co.thinkofdeath.mapviewer.shared.block.BlockFactory;
import uk.co.thinkofdeath.mapviewer.shared.block.states.EnumState;

import java.util.Map;

public class BlockDirt extends BlockFactory {

    public static final String VARIENT = "varient";

    public BlockDirt() {
        states.put(BlockDirt.VARIENT, new EnumState(BlockDirt.Variants.class));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Block createBlock(Map<String, Object> states) {
        return new BlockImpl(this, states);
    }

    public static enum Variants {
        DEFAULT,
        GRASSLESS,
        PODZOL;

        /**
         * {@inheritDoc}
         */
        @Override
        public String toString() {
            return super.toString().toLowerCase();
        }
    }

    public static class BlockImpl extends Block {

        BlockImpl(BlockFactory factory, Map<String, Object> state) {
            super(factory, state);
        }

        @Override
        public int getLegacyData() {
            return ((Variants) getState(VARIENT)).ordinal();
        }
    }
}

@@ -652,16 +652,65 @@
 locks;%0A%0A
+import uk.co.thinkofdeath.mapviewer.shared.Face;%0A
 import u
@@ -757,16 +757,16 @@
 .Block;%0A
-
 import u
@@ -1092,26 +1092,15 @@
 ate(
-BlockDirt.
 Variant
-s
 .cla
@@ -1306,17 +1306,16 @@
  Variant
-s
  %7B%0A     
@@ -1529,37 +1529,38 @@
   %7D%0A    %7D%0A%0A    p
-ublic
+rivate
  static class Bl
@@ -1777,20 +1777,22 @@
 urn 
-((
+this.%3C
 Variant
-s) 
+%3E
 getS
@@ -1804,17 +1804,16 @@
 VARIENT)
-)
 .ordinal
@@ -1821,21 +1821,499 @@
 );%0A        %7D
+%0A%0A        @Override%0A        public String getTexture(Face face) %7B%0A            if (getState(VARIENT) == Variant.PODZOL) %7B%0A                switch (face) %7B%0A                    case TOP:%0A                        return %22dirt_podzol_top%22;%0A                    case BOTTOM:%0A                        return %22dirt%22;%0A                    default:%0A                        return %22dirt_podzol_side%22;%0A                %7D%0A            %7D else %7B%0A                return %22dirt%22;%0A            %7D%0A        %7D
 %0A    %7D%0A%7D%0A

Correct textures for dirt (and sub-blocks)