Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Pumpkin.java
1 package org.bukkit.material;
2 
3 import org.bukkit.Material;
5 
6 /**
7  * Represents a pumpkin.
8  */
9 public class Pumpkin extends MaterialData implements Directional {
10 
11  public Pumpkin() {
12  super(Material.PUMPKIN);
13  }
14 
15  /**
16  * Instantiate a pumpkin facing in a particular direction.
17  *
18  * @param direction the direction the pumkin's face is facing
19  */
20  public Pumpkin(BlockFace direction) {
21  this();
22  setFacingDirection(direction);
23  }
24 
25  /**
26  *
27  * @deprecated Magic value
28  */
29  @Deprecated
30  public Pumpkin(final int type) {
31  super(type);
32  }
33 
34  public Pumpkin(final Material type) {
35  super(type);
36  }
37 
38  /**
39  *
40  * @deprecated Magic value
41  */
42  @Deprecated
43  public Pumpkin(final int type, final byte data) {
44  super(type, data);
45  }
46 
47  /**
48  *
49  * @deprecated Magic value
50  */
51  @Deprecated
52  public Pumpkin(final Material type, final byte data) {
53  super(type, data);
54  }
55 
56  public boolean isLit() {
57  return getItemType() == Material.JACK_O_LANTERN;
58  }
59 
60  public void setFacingDirection(BlockFace face) {
61  byte data;
62 
63  switch (face) {
64  case NORTH:
65  data = 0x0;
66  break;
67 
68  case EAST:
69  data = 0x1;
70  break;
71 
72  case SOUTH:
73  data = 0x2;
74  break;
75 
76  case WEST:
77  default:
78  data = 0x3;
79  }
80 
81  setData(data);
82  }
83 
84  public BlockFace getFacing() {
85  byte data = getData();
86 
87  switch (data) {
88  case 0x0:
89  return BlockFace.NORTH;
90 
91  case 0x1:
92  return BlockFace.EAST;
93 
94  case 0x2:
95  return BlockFace.SOUTH;
96 
97  case 0x3:
98  default:
99  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 }
void setFacingDirection(BlockFace face)
Definition: Pumpkin.java:60
Pumpkin(final int type, final byte data)
Definition: Pumpkin.java:43
Pumpkin(BlockFace direction)
Definition: Pumpkin.java:20
Pumpkin(final Material type, final byte data)
Definition: Pumpkin.java:52
Pumpkin(final int type)
Definition: Pumpkin.java:30