1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
package org.bukkit.craftbukkit;
import org.bukkit.*;
public class CraftBlock implements Block {
private final World world;
private final Chunk chunk;
private final int x;
private final int y;
private final int z;
protected int type;
protected byte data;
protected CraftBlock(final World world, final int x, final int y, final int z, final int type, final byte data) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.type = type;
this.data = data;
this.chunk = world.getChunkAt(x << 4, z << 4);
}
/**
* Gets the world which contains this Block
*
* @return World containing this block
*/
public World getWorld() {
return world;
}
/**
* Gets the x-coordinate of this block
*
* @return x-coordinate
*/
public int getX() {
return x;
}
/**
* Gets the y-coordinate of this block
*
* @return y-coordinate
*/
public int getY() {
return y;
}
/**
* Gets the z-coordinate of this block
*
* @return z-coordinate
*/
public int getZ() {
return z;
}
/**
* Gets the chunk which contains this block
*
* @return Containing Chunk
*/
public Chunk getChunk() {
return chunk;
}
/**
* Sets the metadata for this block
*
* @param data New block specific metadata
*/
public void setData(final byte data) {
this.data = data;
}
/**
* Gets the metadata for this block
*
* @return block specific metadata
*/
public byte getData() {
return data;
}
/**
* Sets the type-ID of this block
*
* @param type Type-ID to change this block to
*/
public void setType(final int type) {
this.type = type;
}
/**
* Gets the type-ID of this block
*
* @return block type-ID
*/
public int getType() {
return type;
}
/**
* Gets the block at the given face
*
* @param face Face of this block to return
* @return Block at the given face
*/
public Block getFace(final BlockFace face) {
return getRelative(face.getModX(), face.getModY(), face.getModZ());
}
/**
* Gets the block at the given offsets
*
* @param modX X-coordinate offset
* @param modY Y-coordinate offset
* @param modZ Z-coordinate offset
* @return Block at the given offsets
*/
public Block getRelative(final int modX, final int modY, final int modZ) {
return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ);
}
}
|