-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockPressurePlate.java
More file actions
194 lines (174 loc) · 5.82 KB
/
BlockPressurePlate.java
File metadata and controls
194 lines (174 loc) · 5.82 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
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.List;
import java.util.Random;
public class BlockPressurePlate extends Block
{
protected BlockPressurePlate(int i, int j, EnumMobType enummobtype)
{
super(i, j, Material.rock);
triggerMobType = enummobtype;
setTickOnLoad(true);
float f = 0.0625F;
setBlockBounds(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
}
public int tickRate()
{
return 20;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
return world.isBlockOpaqueCube(i, j - 1, k);
}
public void onBlockAdded(World world, int i, int j, int k)
{
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
boolean flag = false;
if(!world.isBlockOpaqueCube(i, j - 1, k))
{
flag = true;
}
if(flag)
{
dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
world.setBlockWithNotify(i, j, k, 0);
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(world.multiplayerWorld)
{
return;
}
if(world.getBlockMetadata(i, j, k) == 0)
{
return;
} else
{
setStateIfMobInteractsWithPlate(world, i, j, k);
return;
}
}
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
if(world.multiplayerWorld)
{
return;
}
if(world.getBlockMetadata(i, j, k) == 1)
{
return;
} else
{
setStateIfMobInteractsWithPlate(world, i, j, k);
return;
}
}
private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k)
{
boolean flag = world.getBlockMetadata(i, j, k) == 1;
boolean flag1 = false;
float f = 0.125F;
List list = null;
if(triggerMobType == EnumMobType.everything)
{
list = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (double)j + 0.25D, (float)(k + 1) - f));
}
if(triggerMobType == EnumMobType.mobs)
{
list = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (double)j + 0.25D, (float)(k + 1) - f));
}
if(triggerMobType == EnumMobType.players)
{
list = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (double)j + 0.25D, (float)(k + 1) - f));
}
if(list.size() > 0)
{
flag1 = true;
}
if(flag1 && !flag)
{
world.setBlockMetadataWithNotify(i, j, k, 1);
world.notifyBlocksOfNeighborChange(i, j, k, blockID);
world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
world.markBlocksDirty(i, j, k, i, j, k);
world.playSoundEffect((double)i + 0.5D, (double)j + 0.10000000000000001D, (double)k + 0.5D, "random.click", 0.3F, 0.6F);
}
if(!flag1 && flag)
{
world.setBlockMetadataWithNotify(i, j, k, 0);
world.notifyBlocksOfNeighborChange(i, j, k, blockID);
world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
world.markBlocksDirty(i, j, k, i, j, k);
world.playSoundEffect((double)i + 0.5D, (double)j + 0.10000000000000001D, (double)k + 0.5D, "random.click", 0.3F, 0.5F);
}
if(flag1)
{
world.func_22136_c(i, j, k, blockID, tickRate());
}
}
public void onBlockRemoval(World world, int i, int j, int k)
{
int l = world.getBlockMetadata(i, j, k);
if(l > 0)
{
world.notifyBlocksOfNeighborChange(i, j, k, blockID);
world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
}
super.onBlockRemoval(world, i, j, k);
}
public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
{
boolean flag = iblockaccess.getBlockMetadata(i, j, k) == 1;
float f = 0.0625F;
if(flag)
{
setBlockBounds(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
} else
{
setBlockBounds(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
}
}
public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return iblockaccess.getBlockMetadata(i, j, k) > 0;
}
public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l)
{
if(world.getBlockMetadata(i, j, k) == 0)
{
return false;
} else
{
return l == 1;
}
}
public boolean canProvidePower()
{
return true;
}
public void func_237_e()
{
float f = 0.5F;
float f1 = 0.125F;
float f2 = 0.5F;
setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
}
private EnumMobType triggerMobType;
}