001    package org.bukkit.material;
002    
003    import java.util.ArrayList;
004    import java.util.List;
005    
006    import org.bukkit.Material;
007    
008    /**
009     * Represents the different types of steps.
010     */
011    public class Step extends TexturedMaterial {
012        private static final List<Material> textures = new ArrayList<Material>();
013        static {
014            textures.add(Material.STONE);
015            textures.add(Material.SANDSTONE);
016            textures.add(Material.WOOD);
017            textures.add(Material.COBBLESTONE);
018            textures.add(Material.BRICK);
019            textures.add(Material.SMOOTH_BRICK);
020            textures.add(Material.NETHER_BRICK);
021            textures.add(Material.QUARTZ_BLOCK);
022        }
023    
024        public Step() {
025            super(Material.STEP);
026        }
027    
028        /**
029         *
030         * @deprecated Magic value
031         */
032        @Deprecated
033        public Step(final int type) {
034            super(type);
035        }
036    
037        public Step(final Material type) {
038            super((textures.contains(type)) ? Material.STEP : type);
039            if (textures.contains(type)) {
040                setMaterial(type);
041            }
042        }
043    
044        /**
045         *
046         * @deprecated Magic value
047         */
048        @Deprecated
049        public Step(final int type, final byte data) {
050            super(type, data);
051        }
052    
053        /**
054         *
055         * @deprecated Magic value
056         */
057        @Deprecated
058        public Step(final Material type, final byte data) {
059            super(type, data);
060        }
061    
062        @Override
063        public List<Material> getTextures() {
064            return textures;
065        }
066    
067        /**
068         * Test if step is inverted
069         *
070         * @return true if inverted (top half), false if normal (bottom half)
071         */
072        public boolean isInverted() {
073            return ((getData() & 0x8) != 0);
074        }
075    
076        /**
077         * Set step inverted state
078         *
079         * @param inv - true if step is inverted (top half), false if step is
080         *     normal (bottom half)
081         */
082        public void setInverted(boolean inv) {
083            int dat = getData() & 0x7;
084            if (inv) {
085                dat |= 0x8;
086            }
087            setData((byte) dat);
088        }
089    
090        /**
091         *
092         * @deprecated Magic value
093         */
094        @Deprecated
095        @Override
096        protected int getTextureIndex() {
097            return getData() & 0x7;
098        }
099    
100        /**
101         *
102         * @deprecated Magic value
103         */
104        @Deprecated
105        @Override
106        protected void setTextureIndex(int idx) {
107            setData((byte) ((getData() & 0x8) | idx));
108        }
109    
110        @Override
111        public Step clone() {
112            return (Step) super.clone();
113        }
114    
115        @Override
116        public String toString() {
117            return super.toString() + (isInverted()?"inverted":"");
118        }
119    }