001 package org.bukkit.material; 002 003 import org.bukkit.Material; 004 import org.bukkit.TreeSpecies; 005 006 /** 007 * Represents the different types of wooden steps. 008 */ 009 public class WoodenStep extends MaterialData { 010 011 public WoodenStep() { 012 super(Material.WOOD_STEP); 013 } 014 015 /** 016 * 017 * @deprecated Magic value 018 */ 019 @Deprecated 020 public WoodenStep(final int type) { 021 super(type); 022 } 023 024 public WoodenStep(TreeSpecies species) { 025 this(); 026 setSpecies(species); 027 } 028 029 public WoodenStep(TreeSpecies species, boolean inv) { 030 this(); 031 setSpecies(species); 032 setInverted(inv); 033 } 034 035 /** 036 * 037 * @deprecated Magic value 038 */ 039 @Deprecated 040 public WoodenStep(final int type, final byte data) { 041 super(type, data); 042 } 043 044 /** 045 * 046 * @deprecated Magic value 047 */ 048 @Deprecated 049 public WoodenStep(final Material type, final byte data) { 050 super(type, data); 051 } 052 053 /** 054 * Gets the current species of this tree 055 * 056 * @return TreeSpecies of this tree 057 */ 058 public TreeSpecies getSpecies() { 059 return TreeSpecies.getByData((byte) (getData() & 0x3)); 060 } 061 062 /** 063 * Sets the species of this tree 064 * 065 * @param species New species of this tree 066 */ 067 public void setSpecies(TreeSpecies species) { 068 setData((byte) ((getData() & 0xC) | species.getData())); 069 } 070 071 /** 072 * Test if step is inverted 073 * 074 * @return true if inverted (top half), false if normal (bottom half) 075 */ 076 public boolean isInverted() { 077 return ((getData() & 0x8) != 0); 078 } 079 080 /** 081 * Set step inverted state 082 * 083 * @param inv - true if step is inverted (top half), false if step is 084 * normal (bottom half) 085 */ 086 public void setInverted(boolean inv) { 087 int dat = getData() & 0x7; 088 if (inv) { 089 dat |= 0x8; 090 } 091 setData((byte) dat); 092 } 093 094 @Override 095 public WoodenStep clone() { 096 return (WoodenStep) super.clone(); 097 } 098 099 @Override 100 public String toString() { 101 return super.toString() + " " + getSpecies() + (isInverted()?" inverted":""); 102 } 103 }