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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
protected BlockPoweredRail() {
super(true);
}
protected boolean a(World world, int i, int j, int k, int l, boolean flag, int i1) {
if (i1 >= 8) {
return false;
} else {
int j1 = l & 0x7;
boolean flag1 = true;
switch (j1) {
case 0:
if (flag) {
++k;
} else {
--k;
}
break;
case 1:
if (flag) {
--i;
} else {
++i;
}
break;
case 2:
if (flag) {
i--;
} else {
++i;
++j;
flag1 = false;
}
j1 = 1;
break;
case 3:
if (flag) {
--i;
++j;
flag1 = false;
} else {
++i;
}
j1 = 1;
break;
case 4:
if (flag) {
++k;
} else {
--k;
++j;
flag1 = false;
}
j1 = 0;
break;
case 5:
if (flag) {
++k;
++j;
flag1 = false;
} else {
--k;
}
j1 = 0;
}
return this.a(world, i, j, k, flag, i1, j1) ? true : flag1 && this.a(world, i, j - 1, k, flag, i1, j1);
}
}
protected boolean a(World world, int i, int j, int k, boolean flag, int l, int i1) {
Block block = world.getType(i, j, k);
if (block == this) {
int j1 = world.getData(i, j, k);
int k1 = j1 & 0x7;
if (i1 == 1 && (k1 == 0 || k1 == 4 || k1 == 5)) {
return false;
}
if (i1 == 0 && (k1 == 1 || k1 == 2 || k1 == 3)) {
return false;
}
if ((j1 & 0x8) != 0) {
if (world.isBlockIndirectlyPowered(i, j, k)) {
return true;
}
return this.a(world, i, j, k, j1, flag, l + 1);
}
}
return false;
}
protected void a(World world, int i, int j, int k, int l, int i1, Block block) {
boolean flag = world.isBlockIndirectlyPowered(i, j, k);
flag = flag || this.a(world, i, j, k, l, true, 0) || this.a(world, i, j, k, l, false, 0);
boolean flag1 = false;
if (flag && (l & 0x8) == 0) {
// CraftBukkit start
if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() <= 0) {
return;
}
// CraftBukkit end
world.setData(i, j, k, i1 | 0x8, 3);
flag1 = true;
} else if (!flag && (l & 0x8) != 0) {
// CraftBukkit start
if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() > 0) {
return;
}
// CraftBukkit end
world.setData(i, j, k, i1, 3);
flag1 = true;
}
if (flag1) {
world.applyPhysics(i, j - 1, k, this);
if (i1 == 2 || i1 == 3 || i1 == 4 || i1 == 5) {
world.applyPhysics(i, j + 1, k, this);
}
}
}
}
|