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