Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.material.Mushroom Class Reference
Inheritance diagram for org.bukkit.material.Mushroom:
org.bukkit.material.MaterialData

Public Member Functions

 Mushroom (Material shroom)
 
 Mushroom (Material shroom, byte data)
 
 Mushroom (int type, byte data)
 
boolean isStem ()
 
void setStem ()
 
boolean isFacePainted (BlockFace face)
 
void setFacePainted (BlockFace face, boolean painted)
 
Set< BlockFacegetPaintedFaces ()
 
String toString ()
 
Mushroom clone ()
 
- Public Member Functions inherited from org.bukkit.material.MaterialData
 MaterialData (final int type)
 
 MaterialData (final Material type)
 
 MaterialData (final int type, final byte data)
 
 MaterialData (final Material type, final byte data)
 
byte getData ()
 
void setData (byte data)
 
Material getItemType ()
 
int getItemTypeId ()
 
ItemStack toItemStack ()
 
ItemStack toItemStack (int amount)
 
String toString ()
 
int hashCode ()
 
boolean equals (Object obj)
 
MaterialData clone ()
 

Detailed Description

Represents a huge mushroom block

Definition at line 13 of file Mushroom.java.

Constructor & Destructor Documentation

org.bukkit.material.Mushroom.Mushroom ( Material  shroom,
byte  data 
)
Deprecated:
Magic value

Definition at line 34 of file Mushroom.java.

34  {
35  super(shroom, data);
36  Validate.isTrue(shroom == Material.HUGE_MUSHROOM_1 || shroom == Material.HUGE_MUSHROOM_2, "Not a mushroom!");
37  }
org.bukkit.material.Mushroom.Mushroom ( int  type,
byte  data 
)
Deprecated:
Magic value

Definition at line 44 of file Mushroom.java.

44  {
45  super(type, data);
46  Validate.isTrue(type == Material.HUGE_MUSHROOM_1.getId() || type == Material.HUGE_MUSHROOM_2.getId(), "Not a mushroom!");
47  }

Member Function Documentation

Set<BlockFace> org.bukkit.material.Mushroom.getPaintedFaces ( )
Returns
A set of all faces that are currently painted (an empty set if it is a stem)

Definition at line 162 of file Mushroom.java.

References org.bukkit.material.Mushroom.isFacePainted().

162  {
163  EnumSet<BlockFace> faces = EnumSet.noneOf(BlockFace.class);
164 
165  if (isFacePainted(BlockFace.WEST)) {
166  faces.add(BlockFace.WEST);
167  }
168 
169  if (isFacePainted(BlockFace.NORTH)) {
170  faces.add(BlockFace.NORTH);
171  }
172 
173  if (isFacePainted(BlockFace.SOUTH)) {
174  faces.add(BlockFace.SOUTH);
175  }
176 
177  if (isFacePainted(BlockFace.EAST)) {
178  faces.add(BlockFace.EAST);
179  }
180 
181  if (isFacePainted(BlockFace.UP)) {
182  faces.add(BlockFace.UP);
183  }
184 
185  return faces;
186  }
boolean isFacePainted(BlockFace face)
Definition: Mushroom.java:69
boolean org.bukkit.material.Mushroom.isFacePainted ( BlockFace  face)

Checks whether a face of the block is painted.

Parameters
faceThe face to check.
Returns
True if it is painted.

Definition at line 69 of file Mushroom.java.

References org.bukkit.material.MaterialData.getData().

Referenced by org.bukkit.material.Mushroom.getPaintedFaces(), and org.bukkit.material.Mushroom.setFacePainted().

69  {
70  byte data = getData();
71 
72  if (data == SHROOM_NONE || data == SHROOM_STEM) {
73  return false;
74  }
75 
76  switch (face) {
77  case WEST:
78  return data < NORTH_LIMIT;
79  case EAST:
80  return data > SOUTH_LIMIT;
81  case NORTH:
82  return data % EAST_WEST_LIMIT == EAST_REMAINDER;
83  case SOUTH:
84  return data % EAST_WEST_LIMIT == WEST_REMAINDER;
85  case UP:
86  return true;
87  default:
88  return false;
89  }
90  }
boolean org.bukkit.material.Mushroom.isStem ( )
Returns
Whether this is a mushroom stem.

Definition at line 52 of file Mushroom.java.

References org.bukkit.material.MaterialData.getData().

52  {
53  return getData() == SHROOM_STEM;
54  }
void org.bukkit.material.Mushroom.setFacePainted ( BlockFace  face,
boolean  painted 
)

Set a face of the block to be painted or not. Note that due to the nature of how the data is stored, setting a face painted or not is not guaranteed to leave the other faces unchanged.

Parameters
faceThe face to paint or unpaint.
paintedTrue if you want to paint it, false if you want the pores to show.

Definition at line 101 of file Mushroom.java.

References org.bukkit.material.MaterialData.getData(), org.bukkit.material.Mushroom.isFacePainted(), and org.bukkit.material.MaterialData.setData().

101  {
102  if (painted == isFacePainted(face)) {
103  return;
104  }
105 
106  byte data = getData();
107 
108  if (data == SHROOM_STEM) {
109  data = 5;
110  }
111 
112  switch (face) {
113  case WEST:
114  if (painted) {
115  data -= NORTH_SOUTH_MOD;
116  } else {
117  data += NORTH_SOUTH_MOD;
118  }
119 
120  break;
121  case EAST:
122  if (painted) {
123  data += NORTH_SOUTH_MOD;
124  } else {
125  data -= NORTH_SOUTH_MOD;
126  }
127 
128  break;
129  case NORTH:
130  if (painted) {
131  data += EAST_WEST_MOD;
132  } else {
133  data -= EAST_WEST_MOD;
134  }
135 
136  break;
137  case SOUTH:
138  if (painted) {
139  data -= EAST_WEST_MOD;
140  } else {
141  data += EAST_WEST_MOD;
142  }
143 
144  break;
145  case UP:
146  if (!painted) {
147  data = 0;
148  }
149 
150  break;
151  default:
152  throw new IllegalArgumentException("Can't paint that face of a mushroom!");
153  }
154 
155  setData(data);
156  }
boolean isFacePainted(BlockFace face)
Definition: Mushroom.java:69
void org.bukkit.material.Mushroom.setStem ( )

Sets this to be a mushroom stem.

Definition at line 59 of file Mushroom.java.

References org.bukkit.material.MaterialData.setData().

59  {
60  setData((byte) 10);
61  }

The documentation for this class was generated from the following file: