blob: d275c29744c0db3cbaf879dee96befc002e1dbf0 (
plain)
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
|
package gregtech.api.objects.blockupdate;
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
public class RandomCooldown extends Cooldown {
public RandomCooldown(int aMinLengthInTicks, int aMaxLengthInTicks) {
super(aMinLengthInTicks);
if (aMinLengthInTicks <= 0)
throw new IllegalArgumentException("min length should be a positive non-zero number");
if (aMaxLengthInTicks <= 0)
throw new IllegalArgumentException("max length should be a positive non-zero number");
if (aMinLengthInTicks > aMaxLengthInTicks)
throw new IllegalArgumentException("min length should be less or equal to max length");
this.minLengthInTicks = aMinLengthInTicks;
this.maxLengthInTicks = aMaxLengthInTicks;
}
@Override
public void set(long currTickTime) {
super.set(currTickTime);
lengthInTicks = minLengthInTicks + XSTR_INSTANCE.nextInt(maxLengthInTicks - minLengthInTicks + 1);
}
private int minLengthInTicks;
private int maxLengthInTicks;
}
|