Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 140 lines 3.5 kB view raw
1package org.bukkit.block; 2 3import org.bukkit.Chunk; 4import org.bukkit.Material; 5import org.bukkit.World; 6import org.bukkit.material.MaterialData; 7 8/** 9 * Represents a captured state of a block, which will not change automatically. 10 * <p> 11 * Unlike Block, which only one object can exist per coordinate, BlockState can 12 * exist multiple times for any given Block. Note that another plugin may change 13 * the state of the block and you will not know, or they may change the block to 14 * another type entirely, causing your BlockState to become invalid. 15 */ 16public interface BlockState { 17 18 /** 19 * Gets the block represented by this BlockState 20 * 21 * @return Block that this BlockState represents 22 */ 23 Block getBlock(); 24 25 /** 26 * Gets the metadata for this block 27 * 28 * @return block specific metadata 29 */ 30 MaterialData getData(); 31 32 /** 33 * Gets the type of this block 34 * 35 * @return block type 36 */ 37 Material getType(); 38 39 /** 40 * Gets the type-id of this block 41 * 42 * @return block type-id 43 */ 44 int getTypeId(); 45 46 /** 47 * Gets the light level between 0-15 48 * 49 * @return light level 50 */ 51 byte getLightLevel(); 52 53 /** 54 * Gets the world which contains this Block 55 * 56 * @return World containing this block 57 */ 58 World getWorld(); 59 60 /** 61 * Gets the x-coordinate of this block 62 * 63 * @return x-coordinate 64 */ 65 int getX(); 66 67 /** 68 * Gets the y-coordinate of this block 69 * 70 * @return y-coordinate 71 */ 72 int getY(); 73 74 /** 75 * Gets the z-coordinate of this block 76 * 77 * @return z-coordinate 78 */ 79 int getZ(); 80 81 /** 82 * Gets the chunk which contains this block 83 * 84 * @return Containing Chunk 85 */ 86 Chunk getChunk(); 87 88 /** 89 * Sets the metadata for this block 90 * 91 * @param data New block specific metadata 92 */ 93 void setData(MaterialData data); 94 95 /** 96 * Sets the type of this block 97 * 98 * @param type Material to change this block to 99 */ 100 void setType(Material type); 101 102 /** 103 * Sets the type-id of this block 104 * 105 * @param type Type-Id to change this block to 106 */ 107 boolean setTypeId(int type); 108 109 /** 110 * Attempts to update the block represented by this state, setting it to the 111 * new values as defined by this state. <br /> 112 * <br /> 113 * This has the same effect as calling update(false). That is to say, 114 * this will not modify the state of a block if it is no longer the same 115 * type as it was when this state was taken. It will return false in this 116 * eventuality. 117 * 118 * @return true if the update was successful, otherwise false 119 * @see BlockState.update(boolean force) 120 */ 121 boolean update(); 122 123 /** 124 * Attempts to update the block represented by this state, setting it to the 125 * new values as defined by this state. <br /> 126 * <br /> 127 * Unless force is true, this will not modify the state of a block if it is 128 * no longer the same type as it was when this state was taken. It will return 129 * false in this eventuality.<br /> 130 * <br /> 131 * If force is true, it will set the type of the block to match the new state, 132 * set the state data and then return true. 133 * 134 * @param force true to forcefully set the state 135 * @return true if the update was successful, otherwise false 136 */ 137 boolean update(boolean force); 138 139 public byte getRawData(); 140}