001 package org.bukkit.material; 002 003 import org.bukkit.Material; 004 import org.bukkit.block.BlockFace; 005 006 /** 007 * Represents a furnace or a dispenser. 008 */ 009 public class DirectionalContainer extends MaterialData implements Directional { 010 /** 011 * 012 * @deprecated Magic value 013 */ 014 @Deprecated 015 public DirectionalContainer(final int type) { 016 super(type); 017 } 018 019 public DirectionalContainer(final Material type) { 020 super(type); 021 } 022 023 /** 024 * 025 * @deprecated Magic value 026 */ 027 @Deprecated 028 public DirectionalContainer(final int type, final byte data) { 029 super(type, data); 030 } 031 032 /** 033 * 034 * @deprecated Magic value 035 */ 036 @Deprecated 037 public DirectionalContainer(final Material type, final byte data) { 038 super(type, data); 039 } 040 041 public void setFacingDirection(BlockFace face) { 042 byte data; 043 044 switch (face) { 045 case NORTH: 046 data = 0x2; 047 break; 048 049 case SOUTH: 050 data = 0x3; 051 break; 052 053 case WEST: 054 data = 0x4; 055 break; 056 057 case EAST: 058 default: 059 data = 0x5; 060 } 061 062 setData(data); 063 } 064 065 public BlockFace getFacing() { 066 byte data = getData(); 067 068 switch (data) { 069 case 0x2: 070 return BlockFace.NORTH; 071 072 case 0x3: 073 return BlockFace.SOUTH; 074 075 case 0x4: 076 return BlockFace.WEST; 077 078 case 0x5: 079 default: 080 return BlockFace.EAST; 081 } 082 } 083 084 @Override 085 public String toString() { 086 return super.toString() + " facing " + getFacing(); 087 } 088 089 @Override 090 public DirectionalContainer clone() { 091 return (DirectionalContainer) super.clone(); 092 } 093 }