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
147
148
149
150
151
152
153
154
155
156
157
158
159
|
package net.minecraft.server;
import java.util.Random;
public class BlockDiode extends Block {
public static final double[] a = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D};
private static final int[] b = new int[] { 1, 2, 3, 4};
private final boolean c;
protected BlockDiode(int i, boolean flag) {
super(i, 6, Material.ORIENTABLE);
this.c = flag;
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return !world.e(i, j - 1, k) ? false : super.canPlace(world, i, j, k);
}
public boolean f(World world, int i, int j, int k) {
return !world.e(i, j - 1, k) ? false : super.f(world, i, j, k);
}
public void a(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k);
boolean flag = this.f(world, i, j, k, l);
if (this.c && !flag) {
world.setTypeIdAndData(i, j, k, Block.DIODE_OFF.id, l);
this.postPlace(world, i, j, k, this.id); // CraftBukkit - update indirect neighbors
} else if (!this.c) {
world.setTypeIdAndData(i, j, k, Block.DIODE_ON.id, l);
this.postPlace(world, i, j, k, this.id); // CraftBukkit - update indirect neighbors
if (!flag) {
int i1 = (l & 12) >> 2;
world.c(i, j, k, Block.DIODE_ON.id, b[i1] * 2);
}
}
}
public int a(int i, int j) {
return i == 0 ? (this.c ? 99 : 115) : (i == 1 ? (this.c ? 147 : 131) : 5);
}
public int c() {
return 15;
}
public int a(int i) {
return this.a(i, 0);
}
public boolean d(World world, int i, int j, int k, int l) {
return this.a(world, i, j, k, l);
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!this.c) {
return false;
} else {
int i1 = iblockaccess.getData(i, j, k) & 3;
return i1 == 0 && l == 3 ? true : (i1 == 1 && l == 4 ? true : (i1 == 2 && l == 2 ? true : i1 == 3 && l == 5));
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!this.f(world, i, j, k)) {
this.b(world, i, j, k, world.getData(i, j, k), 0);
world.setTypeId(i, j, k, 0);
} else {
int i1 = world.getData(i, j, k);
boolean flag = this.f(world, i, j, k, i1);
int j1 = (i1 & 12) >> 2;
if (this.c && !flag) {
world.c(i, j, k, this.id, b[j1] * 2);
} else if (!this.c && flag) {
world.c(i, j, k, this.id, b[j1] * 2);
}
}
}
private boolean f(World world, int i, int j, int k, int l) {
int i1 = l & 3;
switch (i1) {
case 0:
return world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) || world.getTypeId(i, j, k + 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k + 1) > 0;
case 1:
return world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) || world.getTypeId(i - 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i - 1, j, k) > 0;
case 2:
return world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) || world.getTypeId(i, j, k - 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k - 1) > 0;
case 3:
return world.isBlockFaceIndirectlyPowered(i + 1, j, k, 5) || world.getTypeId(i + 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i + 1, j, k) > 0;
default:
return false;
}
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
int l = world.getData(i, j, k);
int i1 = (l & 12) >> 2;
i1 = i1 + 1 << 2 & 12;
world.setData(i, j, k, i1 | l & 3);
return true;
}
public boolean isPowerSource() {
return true;
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
world.setData(i, j, k, l);
boolean flag = this.f(world, i, j, k, l);
if (flag) {
world.c(i, j, k, this.id, 1);
}
}
public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
world.applyPhysics(i + 1, j, k, this.id);
world.applyPhysics(i - 1, j, k, this.id);
world.applyPhysics(i, j, k + 1, this.id);
world.applyPhysics(i, j, k - 1, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
}
public void postBreak(World world, int i, int j, int k, int l) {
if (this.c) {
world.applyPhysics(i, j + 1, k, this.id);
}
super.postBreak(world, i, j, k, l);
}
public boolean a() {
return false;
}
public int getDropType(int i, Random random, int j) {
return Item.DIODE.id;
}
}
|