Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockState.java
1 package org.bukkit.block;
2 
3 import org.bukkit.Chunk;
4 import org.bukkit.Location;
5 import org.bukkit.Material;
6 import org.bukkit.World;
9 
10 /**
11  * Represents a captured state of a block, which will not change
12  * automatically.
13  * <p>
14  * Unlike Block, which only one object can exist per coordinate, BlockState
15  * can exist multiple times for any given Block. Note that another plugin may
16  * change the state of the block and you will not know, or they may change the
17  * block to another type entirely, causing your BlockState to become invalid.
18  */
19 public interface BlockState extends Metadatable {
20 
21  /**
22  * Gets the block represented by this BlockState
23  *
24  * @return Block that this BlockState represents
25  */
26  Block getBlock();
27 
28  /**
29  * Gets the metadata for this block
30  *
31  * @return block specific metadata
32  */
34 
35  /**
36  * Gets the type of this block
37  *
38  * @return block type
39  */
40  Material getType();
41 
42  /**
43  * Gets the type-id of this block
44  *
45  * @return block type-id
46  * @deprecated Magic value
47  */
48  @Deprecated
49  int getTypeId();
50 
51  /**
52  * Gets the light level between 0-15
53  *
54  * @return light level
55  */
56  byte getLightLevel();
57 
58  /**
59  * Gets the world which contains this Block
60  *
61  * @return World containing this block
62  */
63  World getWorld();
64 
65  /**
66  * Gets the x-coordinate of this block
67  *
68  * @return x-coordinate
69  */
70  int getX();
71 
72  /**
73  * Gets the y-coordinate of this block
74  *
75  * @return y-coordinate
76  */
77  int getY();
78 
79  /**
80  * Gets the z-coordinate of this block
81  *
82  * @return z-coordinate
83  */
84  int getZ();
85 
86  /**
87  * Gets the location of this block
88  *
89  * @return location
90  */
92 
93  /**
94  * Stores the location of this block in the provided Location object.
95  * <p>
96  * If the provided Location is null this method does nothing and returns
97  * null.
98  *
99  * @return The Location object provided or null
100  */
102 
103  /**
104  * Gets the chunk which contains this block
105  *
106  * @return Containing Chunk
107  */
108  Chunk getChunk();
109 
110  /**
111  * Sets the metadata for this block
112  *
113  * @param data New block specific metadata
114  */
115  void setData(MaterialData data);
116 
117  /**
118  * Sets the type of this block
119  *
120  * @param type Material to change this block to
121  */
122  void setType(Material type);
123 
124  /**
125  * Sets the type-id of this block
126  *
127  * @param type Type-Id to change this block to
128  * @return Whether it worked?
129  * @deprecated Magic value
130  */
131  @Deprecated
132  boolean setTypeId(int type);
133 
134  /**
135  * Attempts to update the block represented by this state, setting it to
136  * the new values as defined by this state.
137  * <p>
138  * This has the same effect as calling update(false). That is to say,
139  * this will not modify the state of a block if it is no longer the same
140  * type as it was when this state was taken. It will return false in this
141  * eventuality.
142  *
143  * @return true if the update was successful, otherwise false
144  * @see #update(boolean)
145  */
146  boolean update();
147 
148  /**
149  * Attempts to update the block represented by this state, setting it to
150  * the new values as defined by this state.
151  * <p>
152  * This has the same effect as calling update(force, true). That is to
153  * say, this will trigger a physics update to surrounding blocks.
154  *
155  * @param force true to forcefully set the state
156  * @return true if the update was successful, otherwise false
157  */
158  boolean update(boolean force);
159 
160  /**
161  * Attempts to update the block represented by this state, setting it to
162  * the new values as defined by this state.
163  * <p>
164  * Unless force is true, this will not modify the state of a block if it
165  * is no longer the same type as it was when this state was taken. It will
166  * return false in this eventuality.
167  * <p>
168  * If force is true, it will set the type of the block to match the new
169  * state, set the state data and then return true.
170  * <p>
171  * If applyPhysics is true, it will trigger a physics update on
172  * surrounding blocks which could cause them to update or disappear.
173  *
174  * @param force true to forcefully set the state
175  * @param applyPhysics false to cancel updating physics on surrounding
176  * blocks
177  * @return true if the update was successful, otherwise false
178  */
179  boolean update(boolean force, boolean applyPhysics);
180 
181  /**
182  * @return The data as a raw byte.
183  * @deprecated Magic value
184  */
185  @Deprecated
186  public byte getRawData();
187 
188  /**
189  * @param data The new data value for the block.
190  * @deprecated Magic value
191  */
192  @Deprecated
193  public void setRawData(byte data);
194 }
void setType(Material type)
boolean setTypeId(int type)
void setData(MaterialData data)
void setRawData(byte data)