001 package org.bukkit.material; 002 003 import org.bukkit.block.BlockFace; 004 import org.bukkit.Material; 005 006 /** 007 * Represents Ladder data 008 */ 009 public class Ladder extends SimpleAttachableMaterialData { 010 public Ladder() { 011 super(Material.LADDER); 012 } 013 014 /** 015 * 016 * @deprecated Magic value 017 */ 018 @Deprecated 019 public Ladder(final int type) { 020 super(type); 021 } 022 023 public Ladder(final Material type) { 024 super(type); 025 } 026 027 /** 028 * 029 * @deprecated Magic value 030 */ 031 @Deprecated 032 public Ladder(final int type, final byte data) { 033 super(type, data); 034 } 035 036 /** 037 * 038 * @deprecated Magic value 039 */ 040 @Deprecated 041 public Ladder(final Material type, final byte data) { 042 super(type, data); 043 } 044 045 /** 046 * Gets the face that this block is attached on 047 * 048 * @return BlockFace attached to 049 */ 050 public BlockFace getAttachedFace() { 051 byte data = getData(); 052 053 switch (data) { 054 case 0x2: 055 return BlockFace.SOUTH; 056 057 case 0x3: 058 return BlockFace.NORTH; 059 060 case 0x4: 061 return BlockFace.EAST; 062 063 case 0x5: 064 return BlockFace.WEST; 065 } 066 067 return null; 068 } 069 070 /** 071 * Sets the direction this ladder is facing 072 */ 073 public void setFacingDirection(BlockFace face) { 074 byte data = (byte) 0x0; 075 076 switch (face) { 077 case SOUTH: 078 data = 0x2; 079 break; 080 081 case NORTH: 082 data = 0x3; 083 break; 084 085 case EAST: 086 data = 0x4; 087 break; 088 089 case WEST: 090 data = 0x5; 091 break; 092 } 093 094 setData(data); 095 096 } 097 098 @Override 099 public Ladder clone() { 100 return (Ladder) super.clone(); 101 } 102 }