blob: 25e3db4869720c9d023faeb657f5fc7f6b32d234 (
plain)
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
|
package org.bukkit.material;
import org.bukkit.Material;
public class Cake extends MaterialData {
public Cake() {
super(Material.LEGACY_CAKE_BLOCK);
}
public Cake(Material type) {
super(type);
}
/**
* @param type the type
* @param data the raw data value
* @deprecated Magic value
*/
@Deprecated
public Cake(Material type, byte data) {
super(type, data);
}
/**
* Gets the number of slices eaten from this cake
*
* @return The number of slices eaten
*/
public int getSlicesEaten() {
return getData();
}
/**
* Gets the number of slices remaining on this cake
*
* @return The number of slices remaining
*/
public int getSlicesRemaining() {
return 6 - getData();
}
/**
* Sets the number of slices eaten from this cake
*
* @param n The number of slices eaten
*/
public void setSlicesEaten(int n) {
if (n < 6) {
setData((byte) n);
} // TODO: else destroy the block? Probably not possible though
}
/**
* Sets the number of slices remaining on this cake
*
* @param n The number of slices remaining
*/
public void setSlicesRemaining(int n) {
if (n > 6) {
n = 6;
}
setData((byte) (6 - n));
}
@Override
public String toString() {
return super.toString() + " " + getSlicesEaten() + "/" + getSlicesRemaining() + " slices eaten/remaining";
}
@Override
public Cake clone() {
return (Cake) super.clone();
}
}
|