forked from CloudburstMC/Nukkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockBambooBlock.java
More file actions
74 lines (62 loc) · 1.63 KB
/
BlockBambooBlock.java
File metadata and controls
74 lines (62 loc) · 1.63 KB
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 cn.nukkit.block;
import cn.nukkit.Player;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemBlock;
import cn.nukkit.math.BlockFace;
public class BlockBambooBlock extends BlockWood {
public BlockBambooBlock() {
this(0);
}
public BlockBambooBlock(int meta) {
super(meta);
}
@Override
public String getName() {
return "Bamboo Block";
}
@Override
public int getId() {
return BAMBOO_BLOCK;
}
@Override
protected int getStrippedId() {
return STRIPPED_BAMBOO_BLOCK;
}
@Override
protected int getStrippedDamage() {
return getDamage();
}
@Override
public Item toItem() {
return new ItemBlock(Block.get(this.getId(), 0), 0);
}
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
this.setPillarAxis(face.getAxis());
return this.getLevel().setBlock(block, this, true, true);
}
public void setPillarAxis(BlockFace.Axis axis) {
switch (axis) {
case Y:
this.setDamage(0);
break;
case X:
this.setDamage(1);
break;
case Z:
this.setDamage(2);
break;
}
}
public BlockFace.Axis getPillarAxis() {
switch (this.getDamage() % 3) {
case 2:
return BlockFace.Axis.Z;
case 1:
return BlockFace.Axis.X;
case 0:
default:
return BlockFace.Axis.Y;
}
}
}