forked from CloudburstMC/Nukkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockHoneyBlock.java
More file actions
61 lines (51 loc) · 1.47 KB
/
BlockHoneyBlock.java
File metadata and controls
61 lines (51 loc) · 1.47 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
package cn.nukkit.block;
import cn.nukkit.Player;
import cn.nukkit.entity.Entity;
import cn.nukkit.math.Vector3;
public class BlockHoneyBlock extends BlockSolid {
@Override
public String getName() {
return "Honey Block";
}
@Override
public int getId() {
return HONEY_BLOCK;
}
@Override
public double getHardness() {
return 0;
}
@Override
public double getResistance() {
return 0;
}
@Override
public boolean hasEntityCollision() {
return true;
}
@Override
public void onEntityCollide(Entity entity) {
if (!entity.onGround && entity.motionY <= 0.08 && !(entity instanceof Player)) {
double ex = Math.abs(x + 0.5D - entity.x);
double ez = Math.abs(z + 0.5D - entity.z);
double width = 0.4375D + (double)(entity.getWidth() / 2.0F);
if (ex + 1.0E-3D > width || ez + 1.0E-3D > width) {
Vector3 motion = entity.getMotion();
motion.y = -0.05;
if (entity.motionY < -0.13) {
double m = -0.05 / entity.motionY;
motion.x *= m;
motion.z *= m;
}
if (!entity.getMotion().equals(motion)) {
entity.setMotion(motion);
}
entity.resetFallDistance();
}
}
}
@Override
public double getFrictionFactor() {
return 0.8;
}
}