forked from AgriCraft/AgriCraft
/
IAgriCrop.java
116 lines (94 loc) · 2.88 KB
/
IAgriCrop.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
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
package com.infinityraider.agricraft.api.crop;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import com.infinityraider.agricraft.api.fertilizer.IAgriFertilizable;
import com.infinityraider.agricraft.api.misc.IAgriHarvestable;
import com.infinityraider.agricraft.api.misc.IAgriWeedable;
import com.infinityraider.agricraft.api.plant.IAgriPlant;
import com.infinityraider.agricraft.api.seed.AgriSeed;
import com.infinityraider.agricraft.api.seed.IAgriSeedAcceptor;
import com.infinityraider.agricraft.api.seed.IAgriSeedProvider;
import com.infinityraider.agricraft.api.soil.IAgriSoil;
import java.util.Optional;
/**
* Interface to interact with AgriCraft's crops.
*
* To retrieve the ICrop instance use:
* {@code API.getCrop(World world, int x, int y, int z)}
*/
public interface IAgriCrop extends IAgriSeedProvider, IAgriSeedAcceptor, IAgriWeedable, IAgriFertilizable, IAgriHarvestable {
/**
* Retrieves the location of the crop instance.
*
* @return the crop's position.
*/
BlockPos getPos();
/**
* @return The growth stage of the crop, between 0 and 7 (both inclusive).
*/
int getGrowthStage();
/**
* Sets the growth stage for this crop
*
* @param stage the growth stage, between 0 and 7 (both inclusive).
*/
void setGrowthStage(int stage);
/**
* @return if this crop is a crosscrop
*/
boolean isCrossCrop();
/**
* Converts this crop to a crosscrop or a regular crop
*
* @param status true for crosscrop, false for regular crop
*/
void setCrossCrop(boolean status);
/**
* @return if this crop is fertile and thus can grow
*/
default boolean isFertile() {
return this.getSeed().filter(this::isFertile).isPresent();
}
default boolean isFertile(AgriSeed seed) {
return isFertile(seed.getPlant());
}
boolean isFertile(IAgriPlant plant);
/**
* @return if this crop is fully grown
*/
boolean isMature();
default boolean spawn() {
return false;
}
default boolean spread() {
return false;
}
@Override
default boolean canWeed() {
return this.getPlant().filter(p -> p.isWeedable()).isPresent();
}
@Override
default boolean clearWeed() {
if (this.canWeed()) {
this.removePlant();
return true;
} else {
return false;
}
}
Optional<IAgriSoil> getSoil();
/**
* Utility method to get access to the TileEntity fields and methods for the
* crop.
*
* @return the TileEntity implementing ICrop
*/
TileEntity getTileEntity();
/**
* @return Any additional data this crop might hold
*/
IAdditionalCropData getAdditionalCropData();
List<IAgriCrop> getNeighbours();
List<IAgriCrop> getMatureNeighbours();
}