-
Notifications
You must be signed in to change notification settings - Fork 497
/
CropManager.java
57 lines (47 loc) · 1.48 KB
/
CropManager.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
package buildcraft.api.crops;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class CropManager {
private static List<ICropHandler> handlers = new ArrayList<ICropHandler>();
public static void registerHandler(ICropHandler cropHandler) {
handlers.add(cropHandler);
}
public static boolean isSeed(ItemStack stack) {
for (ICropHandler cropHandler : handlers) {
if (cropHandler.isSeed(stack)) {
return true;
}
}
return false;
}
public static boolean canSustainPlant(World world, ItemStack seed, int x, int y, int z) {
for (ICropHandler cropHandler : handlers) {
if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, x, y, z))
return true;
}
return false;
}
public static boolean isMature(IBlockAccess blockAccess, Block block, int meta, int x, int y,
int z) {
for (ICropHandler cropHandler : handlers) {
if (cropHandler.isMature(blockAccess, block, meta, x, y, z)) {
return true;
}
}
return false;
}
public static boolean harvestCrop(World world, int x, int y, int z, List<ItemStack> drops) {
for (ICropHandler cropHandler : handlers) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (cropHandler.isMature(world, block, meta, x, y, z)) {
return cropHandler.harvestCrop(world, x, y, z, drops);
}
}
return false;
}
}