-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockBed.java
More file actions
213 lines (191 loc) · 5.3 KB
/
BlockBed.java
File metadata and controls
213 lines (191 loc) · 5.3 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
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 BlockBed extends Block
{
public BlockBed(int i)
{
super(i, 134, Material.cloth);
func_22027_j();
}
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
int l = world.getBlockMetadata(i, j, k);
if(!func_22032_d(l))
{
int i1 = func_22030_c(l);
i += field_22033_a[i1][0];
k += field_22033_a[i1][1];
if(world.getBlockId(i, j, k) != blockID)
{
return true;
}
l = world.getBlockMetadata(i, j, k);
}
if(func_22029_f(l))
{
entityplayer.func_22055_b("tile.bed.occupied");
return true;
}
if(entityplayer.func_22053_b(i, j, k))
{
func_22031_a(world, i, j, k, true);
return true;
} else
{
entityplayer.func_22055_b("tile.bed.noSleep");
return true;
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 0)
{
return Block.planks.blockIndexInTexture;
}
int k = func_22030_c(j);
int l = ModelBed.field_22281_c[k][i];
if(func_22032_d(j))
{
if(l == 2)
{
return blockIndexInTexture + 2 + 16;
}
if(l == 5 || l == 4)
{
return blockIndexInTexture + 1 + 16;
} else
{
return blockIndexInTexture + 1;
}
}
if(l == 3)
{
return (blockIndexInTexture - 1) + 16;
}
if(l == 5 || l == 4)
{
return blockIndexInTexture + 16;
} else
{
return blockIndexInTexture;
}
}
public int getRenderType()
{
return 14;
}
public boolean renderAsNormalBlock()
{
return false;
}
public boolean isOpaqueCube()
{
return false;
}
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
{
func_22027_j();
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
int i1 = world.getBlockMetadata(i, j, k);
int j1 = func_22030_c(i1);
if(func_22032_d(i1))
{
if(world.getBlockId(i - field_22033_a[j1][0], j, k - field_22033_a[j1][1]) != blockID)
{
world.setBlockWithNotify(i, j, k, 0);
}
} else
if(world.getBlockId(i + field_22033_a[j1][0], j, k + field_22033_a[j1][1]) != blockID)
{
world.setBlockWithNotify(i, j, k, 0);
if(!world.multiplayerWorld)
{
dropBlockAsItem(world, i, j, k, i1);
}
}
}
public int idDropped(int i, Random random)
{
if(func_22032_d(i))
{
return 0;
} else
{
return Item.field_22019_aY.shiftedIndex;
}
}
private void func_22027_j()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
}
public static int func_22030_c(int i)
{
return i & 3;
}
public static boolean func_22032_d(int i)
{
return (i & 8) != 0;
}
public static boolean func_22029_f(int i)
{
return (i & 4) != 0;
}
public static void func_22031_a(World world, int i, int j, int k, boolean flag)
{
int l = world.getBlockMetadata(i, j, k);
if(flag)
{
l |= 4;
} else
{
l &= -5;
}
world.setBlockMetadataWithNotify(i, j, k, l);
}
public static ChunkCoordinates func_22028_g(World world, int i, int j, int k, int l)
{
int i1 = world.getBlockMetadata(i, j, k);
int j1 = func_22030_c(i1);
for(int k1 = 0; k1 <= 1; k1++)
{
int l1 = i - field_22033_a[j1][0] * k1 - 1;
int i2 = k - field_22033_a[j1][1] * k1 - 1;
int j2 = l1 + 2;
int k2 = i2 + 2;
for(int l2 = l1; l2 <= j2; l2++)
{
for(int i3 = i2; i3 <= k2; i3++)
{
if(!world.isBlockOpaqueCube(l2, j - 1, i3) || !world.isAirBlock(l2, j, i3) || !world.isAirBlock(l2, j + 1, i3))
{
continue;
}
if(l > 0)
{
l--;
} else
{
return new ChunkCoordinates(l2, j, i3);
}
}
}
}
return new ChunkCoordinates(i, j + 1, k);
}
public static final int field_22033_a[][] = {
{
0, 1
}, {
-1, 0
}, {
0, -1
}, {
1, 0
}
};
}