-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockSoil.java
More file actions
133 lines (115 loc) · 3.42 KB
/
BlockSoil.java
File metadata and controls
133 lines (115 loc) · 3.42 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
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 BlockSoil extends Block
{
protected BlockSoil(int i)
{
super(i, Material.ground);
blockIndexInTexture = 87;
setTickOnLoad(true);
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
setLightOpacity(255);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return AxisAlignedBB.getBoundingBoxFromPool(i + 0, j + 0, k + 0, i + 1, j + 1, k + 1);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 1 && j > 0)
{
return blockIndexInTexture - 1;
}
if(i == 1)
{
return blockIndexInTexture;
} else
{
return 2;
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(random.nextInt(5) == 0)
{
if(isWaterNearby(world, i, j, k))
{
world.setBlockMetadataWithNotify(i, j, k, 7);
} else
{
int l = world.getBlockMetadata(i, j, k);
if(l > 0)
{
world.setBlockMetadataWithNotify(i, j, k, l - 1);
} else
if(!isCropsNearby(world, i, j, k))
{
world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
}
}
}
}
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
if(world.rand.nextInt(4) == 0)
{
world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
}
}
private boolean isCropsNearby(World world, int i, int j, int k)
{
int l = 0;
for(int i1 = i - l; i1 <= i + l; i1++)
{
for(int j1 = k - l; j1 <= k + l; j1++)
{
if(world.getBlockId(i1, j + 1, j1) == Block.crops.blockID)
{
return true;
}
}
}
return false;
}
private boolean isWaterNearby(World world, int i, int j, int k)
{
for(int l = i - 4; l <= i + 4; l++)
{
for(int i1 = j; i1 <= j + 1; i1++)
{
for(int j1 = k - 4; j1 <= k + 4; j1++)
{
if(world.getBlockMaterial(l, i1, j1) == Material.water)
{
return true;
}
}
}
}
return false;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
super.onNeighborBlockChange(world, i, j, k, l);
Material material = world.getBlockMaterial(i, j + 1, k);
if(material.isSolid())
{
world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
}
}
public int idDropped(int i, Random random)
{
return Block.dirt.idDropped(0, random);
}
}