-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBlockHut.java
70 lines (56 loc) · 1.77 KB
/
BlockHut.java
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
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockHut extends BlockChest {
protected int hutWidth;
protected int hutHeight;
protected int clearingRange;
protected int halfWidth;
protected int workingRange;
protected int textureID;
public BlockHut(int blockID) {
super(blockID);
setTickOnLoad(true);
// Need to create the item that will be dropped
//Item.itemsList[blockID] = new ItemBlock(blockID - 256);
}
public int idDropped(int i, Random random) {
return blockID;
}
protected int findTopGround(World world, int x, int z) {
int ySolid = world.findTopSolidBlock(x, z);
int blockId = world.getBlockId(x, ySolid, z);
while(blockId==Block.leaves.blockID ||
blockId==Block.wood.blockID ||
blockId==Block.cactus.blockID ||
blockId==Block.crops.blockID ||
blockId==Block.fence.blockID ||
blockId==Block.fire.blockID ||
blockId==0)
{
ySolid--;
blockId = world.getBlockId(x, ySolid, z);
}
return ySolid;
}
// scan for block type in the specified range
protected Vec3D scanForBlockNearPoint(World world, int blockId, int x, int y, int z,
int rx, int ry, int rz) {
Vec3D entityVec = Vec3D.createVector(x, y, z);
Vec3D closestVec = null;
double minDistance = 999999999;
for (int i = x - rx; i <= x + rx; i++)
for (int j = y - ry; j <= y + ry; j++)
for (int k = z - rz; k <= z + rz; k++) {
if (world.getBlockId(i, j, k) == blockId) {
Vec3D tempVec = Vec3D.createVector(i, j, k);
if (closestVec == null
|| tempVec.distanceTo(entityVec) < minDistance) {
closestVec = tempVec;
minDistance = closestVec.distanceTo(entityVec);
}
}
}
return closestVec;
}
}