001 package org.bukkit.material; 002 003 import org.bukkit.Material; 004 import org.bukkit.block.BlockFace; 005 006 /** 007 * Represents a skull. 008 */ 009 public class Skull extends MaterialData implements Directional { 010 public Skull() { 011 super(Material.SKULL); 012 } 013 014 /** 015 * Instantiate a skull facing in a particular direction. 016 * 017 * @param direction the direction the skull's face is facing 018 */ 019 public Skull(BlockFace direction) { 020 this(); 021 setFacingDirection(direction); 022 } 023 024 /** 025 * 026 * @deprecated Magic value 027 */ 028 @Deprecated 029 public Skull(final int type) { 030 super(type); 031 } 032 033 public Skull(final Material type) { 034 super(type); 035 } 036 037 /** 038 * 039 * @deprecated Magic value 040 */ 041 @Deprecated 042 public Skull(final int type, final byte data) { 043 super(type, data); 044 } 045 046 /** 047 * 048 * @deprecated Magic value 049 */ 050 @Deprecated 051 public Skull(final Material type, final byte data) { 052 super(type, data); 053 } 054 055 public void setFacingDirection(BlockFace face) { 056 int data; 057 058 switch (face) { 059 case SELF: 060 default: 061 data = 0x1; 062 break; 063 064 case NORTH: 065 data = 0x2; 066 break; 067 068 case EAST: 069 data = 0x4; 070 break; 071 072 case SOUTH: 073 data = 0x3; 074 break; 075 076 case WEST: 077 data = 0x5; 078 } 079 080 setData((byte) data); 081 } 082 083 public BlockFace getFacing() { 084 int data = getData(); 085 086 switch (data) { 087 case 0x1: 088 default: 089 return BlockFace.SELF; 090 091 case 0x2: 092 return BlockFace.NORTH; 093 094 case 0x3: 095 return BlockFace.SOUTH; 096 097 case 0x4: 098 return BlockFace.EAST; 099 100 case 0x5: 101 return BlockFace.WEST; 102 } 103 } 104 105 @Override 106 public String toString() { 107 return super.toString() + " facing " + getFacing(); 108 } 109 110 @Override 111 public Skull clone() { 112 return (Skull) super.clone(); 113 } 114 }