-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockCrops.java
More file actions
143 lines (128 loc) · 4.18 KB
/
BlockCrops.java
File metadata and controls
143 lines (128 loc) · 4.18 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
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 BlockCrops extends BlockFlower
{
protected BlockCrops(int i, int j)
{
super(i, j);
blockIndexInTexture = j;
setTickOnLoad(true);
float f = 0.5F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
}
protected boolean canThisPlantGrowOnThisBlockID(int i)
{
return i == Block.tilledField.blockID;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
super.updateTick(world, i, j, k, random);
if(world.getBlockLightValue(i, j + 1, k) >= 9)
{
int l = world.getBlockMetadata(i, j, k);
if(l < 7)
{
float f = getGrowthRate(world, i, j, k);
if(random.nextInt((int)(100F / f)) == 0)
{
l++;
world.setBlockMetadataWithNotify(i, j, k, l);
}
}
}
}
public void func_21027_c_(World world, int i, int j, int k)
{
world.setBlockMetadataWithNotify(i, j, k, 7);
}
private float getGrowthRate(World world, int i, int j, int k)
{
float f = 1.0F;
int l = world.getBlockId(i, j, k - 1);
int i1 = world.getBlockId(i, j, k + 1);
int j1 = world.getBlockId(i - 1, j, k);
int k1 = world.getBlockId(i + 1, j, k);
int l1 = world.getBlockId(i - 1, j, k - 1);
int i2 = world.getBlockId(i + 1, j, k - 1);
int j2 = world.getBlockId(i + 1, j, k + 1);
int k2 = world.getBlockId(i - 1, j, k + 1);
boolean flag = j1 == blockID || k1 == blockID;
boolean flag1 = l == blockID || i1 == blockID;
boolean flag2 = l1 == blockID || i2 == blockID || j2 == blockID || k2 == blockID;
for(int l2 = i - 1; l2 <= i + 1; l2++)
{
for(int i3 = k - 1; i3 <= k + 1; i3++)
{
int j3 = world.getBlockId(l2, j - 1, i3);
float f1 = 0.0F;
if(j3 == Block.tilledField.blockID)
{
f1 = 1.0F;
if(world.getBlockMetadata(l2, j - 1, i3) > 0)
{
f1 = 3F;
}
}
if(l2 != i || i3 != k)
{
f1 /= 4F;
}
f += f1;
}
}
if(flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(j < 0)
{
j = 7;
}
return blockIndexInTexture + j;
}
public int getRenderType()
{
return 6;
}
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
{
super.onBlockDestroyedByPlayer(world, i, j, k, l);
if(!world.multiplayerWorld)
{
for(int i1 = 0; i1 < 3; i1++)
{
if(world.rand.nextInt(15) <= l)
{
float f = 0.7F;
float f1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f3 = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(world, (float)i + f1, (float)j + f2, (float)k + f3, new ItemStack(Item.seeds));
entityitem.delayBeforeCanPickup = 10;
world.entityJoinedWorld(entityitem);
}
}
}
}
public int idDropped(int i, Random random)
{
if(i == 7)
{
return Item.wheat.shiftedIndex;
} else
{
return -1;
}
}
public int quantityDropped(Random random)
{
return 1;
}
}