001 package org.bukkit.material; 002 003 import org.bukkit.block.BlockFace; 004 import org.bukkit.Material; 005 006 /** 007 * MaterialData for torches 008 */ 009 public class Torch extends SimpleAttachableMaterialData { 010 public Torch() { 011 super(Material.TORCH); 012 } 013 014 /** 015 * 016 * @deprecated Magic value 017 */ 018 @Deprecated 019 public Torch(final int type) { 020 super(type); 021 } 022 023 public Torch(final Material type) { 024 super(type); 025 } 026 027 /** 028 * 029 * @deprecated Magic value 030 */ 031 @Deprecated 032 public Torch(final int type, final byte data) { 033 super(type, data); 034 } 035 036 /** 037 * 038 * @deprecated Magic value 039 */ 040 @Deprecated 041 public Torch(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 0x1: 055 return BlockFace.WEST; 056 057 case 0x2: 058 return BlockFace.EAST; 059 060 case 0x3: 061 return BlockFace.NORTH; 062 063 case 0x4: 064 return BlockFace.SOUTH; 065 066 case 0x5: 067 default: 068 return BlockFace.DOWN; 069 } 070 } 071 072 public void setFacingDirection(BlockFace face) { 073 byte data; 074 075 switch (face) { 076 case EAST: 077 data = 0x1; 078 break; 079 080 case WEST: 081 data = 0x2; 082 break; 083 084 case SOUTH: 085 data = 0x3; 086 break; 087 088 case NORTH: 089 data = 0x4; 090 break; 091 092 case UP: 093 default: 094 data = 0x5; 095 } 096 097 setData(data); 098 } 099 100 @Override 101 public Torch clone() { 102 return (Torch) super.clone(); 103 } 104 }