package bunyan.blocks;

import bunyan.api.Direction;
import bunyan.api.DirectionalBlock;
import bunyan.api.TurnableLog;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.ItemStack;
import net.minecraft.server.World;

public class TurnableVanillaLog extends TurnableLog
{
    public static final int metaOak = 0;
    public static final int metaPine = 1;
    public static final int metaBirch = 2;
    public static final int metaJungle = 3;
    private static final int[] BARK_OFFSETS = new int[] { -1, 95, 96, 132};

    public TurnableVanillaLog(int var1)
    {
        super(var1, 21);
    }

    public void addCreativeItems(ArrayList var1) {}

    /**
     * Spawns EntityItem in the world for the given ItemStack if the world is not remote.
     */
    protected void a(World var1, int var2, int var3, int var4, ItemStack var5)
    {
        var5.id = (new ItemStack(LOG)).id;
        super.a(var1, var2, var3, var4, var5);
    }

    public int getTextureOffsetFromFacingSideAndMetadata(Direction var1, Direction var2, int var3)
    {
        int var4 = 0;
        int var5 = getDataFromMetadata(var3);

        switch (TurnableVanillaLog.NamelessClass1849955508.$SwitchMap$bunyan$api$Direction[var2.ordinal()])
        {
            case 1:
            case 2:
                var4 = BARK_OFFSETS[var5];
                break;

            case 3:
            case 4:
                if (var1 == Direction.WEST || var1 == Direction.EAST)
                {
                    var4 = BARK_OFFSETS[var5];
                }

                break;

            case 5:
            case 6:
                if (var1 == Direction.NORTH || var1 == Direction.SOUTH)
                {
                    var4 = BARK_OFFSETS[var5];
                }
        }

        return var4;
    }

    /**
     * Returns the ID of the items to drop on destruction.
     */
    public int getDropType(int var1, Random var2, int var3)
    {
        return LOG.id;
    }

    public void onLogTurner(EntityHuman var1, World var2, int var3, int var4, int var5, Direction var6)
    {
        if (var6 != Direction.UP && var6 != Direction.DOWN)
        {
            DirectionalBlock.setFacing(var2, var3, var4, var5, var6, true);
        }
        else
        {
            int var7 = DirectionalBlock.getDataFromMetadata(var2.getData(var3, var4, var5));
            var2.setTypeIdAndData(var3, var4, var5, LOG.id, var7);
        }
    }

    static class NamelessClass1849955508
    {
        static final int[] $SwitchMap$bunyan$api$Direction = new int[Direction.values().length];

        static
        {
            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.DOWN.ordinal()] = 1;
            }
            catch (NoSuchFieldError var6)
            {
                ;
            }

            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.UP.ordinal()] = 2;
            }
            catch (NoSuchFieldError var5)
            {
                ;
            }

            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.NORTH.ordinal()] = 3;
            }
            catch (NoSuchFieldError var4)
            {
                ;
            }

            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.SOUTH.ordinal()] = 4;
            }
            catch (NoSuchFieldError var3)
            {
                ;
            }

            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.WEST.ordinal()] = 5;
            }
            catch (NoSuchFieldError var2)
            {
                ;
            }

            try
            {
                $SwitchMap$bunyan$api$Direction[Direction.EAST.ordinal()] = 6;
            }
            catch (NoSuchFieldError var1)
            {
                ;
            }
        }
    }
}
