-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockRedstoneRepeater.java
More file actions
272 lines (239 loc) · 7.64 KB
/
BlockRedstoneRepeater.java
File metadata and controls
272 lines (239 loc) · 7.64 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
import java.util.Random;
public class BlockRedstoneRepeater extends Block
{
protected BlockRedstoneRepeater(int i, boolean flag)
{
super(i, 102, Material.circuits);
field_22025_c = flag;
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean renderAsNormalBlock()
{
return false;
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
if(!world.isBlockOpaqueCube(i, j - 1, k))
{
return false;
} else
{
return super.canPlaceBlockAt(world, i, j, k);
}
}
public boolean canBlockStay(World world, int i, int j, int k)
{
if(!world.isBlockOpaqueCube(i, j - 1, k))
{
return false;
} else
{
return super.canBlockStay(world, i, j, k);
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
int l = world.getBlockMetadata(i, j, k);
boolean flag = func_22022_g(world, i, j, k, l);
if(field_22025_c && !flag)
{
world.setBlockAndMetadataWithNotify(i, j, k, Block.field_22021_bh.blockID, l);
} else
if(!field_22025_c)
{
world.setBlockAndMetadataWithNotify(i, j, k, Block.field_22020_bi.blockID, l);
if(!flag)
{
int i1 = (l & 0xc) >> 2;
world.func_22136_c(i, j, k, Block.field_22020_bi.blockID, field_22023_b[i1] * 2);
}
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 0)
{
return !field_22025_c ? 115 : 99;
}
if(i == 1)
{
return !field_22025_c ? 131 : 147;
} else
{
return 5;
}
}
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return l != 0 && l != 1;
}
public int getRenderType()
{
return 15;
}
public int getBlockTextureFromSide(int i)
{
return getBlockTextureFromSideAndMetadata(i, 0);
}
public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l)
{
return isPoweringTo(world, i, j, k, l);
}
public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
if(!field_22025_c)
{
return false;
}
int i1 = iblockaccess.getBlockMetadata(i, j, k) & 3;
if(i1 == 0 && l == 3)
{
return true;
}
if(i1 == 1 && l == 4)
{
return true;
}
if(i1 == 2 && l == 2)
{
return true;
}
return i1 == 3 && l == 5;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if(!canBlockStay(world, i, j, k))
{
dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
world.setBlockWithNotify(i, j, k, 0);
return;
}
int i1 = world.getBlockMetadata(i, j, k);
boolean flag = func_22022_g(world, i, j, k, i1);
int j1 = (i1 & 0xc) >> 2;
if(field_22025_c && !flag)
{
world.func_22136_c(i, j, k, blockID, field_22023_b[j1] * 2);
} else
if(!field_22025_c && flag)
{
world.func_22136_c(i, j, k, blockID, field_22023_b[j1] * 2);
}
}
private boolean func_22022_g(World world, int i, int j, int k, int l)
{
int i1 = l & 3;
switch(i1)
{
case 0: // '\0'
return world.isBlockIndirectlyProvidingPowerTo(i, j, k + 1, 3);
case 2: // '\002'
return world.isBlockIndirectlyProvidingPowerTo(i, j, k - 1, 2);
case 3: // '\003'
return world.isBlockIndirectlyProvidingPowerTo(i + 1, j, k, 5);
case 1: // '\001'
return world.isBlockIndirectlyProvidingPowerTo(i - 1, j, k, 4);
}
return false;
}
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
int l = world.getBlockMetadata(i, j, k);
int i1 = (l & 0xc) >> 2;
i1 = i1 + 1 << 2 & 0xc;
world.setBlockMetadataWithNotify(i, j, k, i1 | l & 3);
return true;
}
public boolean canProvidePower()
{
return false;
}
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
{
int l = ((MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3) + 2) % 4;
world.setBlockMetadataWithNotify(i, j, k, l);
boolean flag = func_22022_g(world, i, j, k, l);
if(flag)
{
world.func_22136_c(i, j, k, blockID, 1);
}
}
public void onBlockAdded(World world, int i, int j, int k)
{
world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
}
public boolean isOpaqueCube()
{
return false;
}
public int idDropped(int i, Random random)
{
return Item.field_22018_aZ.shiftedIndex;
}
public void randomDisplayTick(World world, int i, int j, int k, Random random)
{
if(!field_22025_c)
{
return;
}
int l = world.getBlockMetadata(i, j, k);
double d = (double)((float)i + 0.5F) + (double)(random.nextFloat() - 0.5F) * 0.20000000000000001D;
double d1 = (double)((float)j + 0.4F) + (double)(random.nextFloat() - 0.5F) * 0.20000000000000001D;
double d2 = (double)((float)k + 0.5F) + (double)(random.nextFloat() - 0.5F) * 0.20000000000000001D;
double d3 = 0.0D;
double d4 = 0.0D;
if(random.nextInt(2) == 0)
{
switch(l & 3)
{
case 0: // '\0'
d4 = -0.3125D;
break;
case 2: // '\002'
d4 = 0.3125D;
break;
case 3: // '\003'
d3 = -0.3125D;
break;
case 1: // '\001'
d3 = 0.3125D;
break;
}
} else
{
int i1 = (l & 0xc) >> 2;
switch(l & 3)
{
case 0: // '\0'
d4 = field_22024_a[i1];
break;
case 2: // '\002'
d4 = -field_22024_a[i1];
break;
case 3: // '\003'
d3 = field_22024_a[i1];
break;
case 1: // '\001'
d3 = -field_22024_a[i1];
break;
}
}
world.spawnParticle("reddust", d + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
}
public static final double field_22024_a[] = {
-0.0625D, 0.0625D, 0.1875D, 0.3125D
};
private static final int field_22023_b[] = {
1, 2, 3, 4
};
private final boolean field_22025_c;
}