Dieser Commit ist enthalten in:
Ursprung
b137aaec24
Commit
3f5784cecb
@ -40,7 +40,8 @@ import java.util.Random;
|
||||
public abstract class SpecialItem {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static boolean lastItemWasSupportItem = false;
|
||||
private static long missileCount = 0;
|
||||
private static long supportCount = 0;
|
||||
|
||||
private static List<SpecialItem> supportItems = new ArrayList<>();
|
||||
private static List<SpecialItem> missileItems = new ArrayList<>();
|
||||
@ -110,11 +111,21 @@ public abstract class SpecialItem {
|
||||
}
|
||||
|
||||
public static ItemStack getRandomItem() {
|
||||
if (!lastItemWasSupportItem && random.nextDouble() > Config.MissileChance) {
|
||||
lastItemWasSupportItem = true;
|
||||
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
||||
double missile = missileCount * Config.MissileChance;
|
||||
double support = supportCount;
|
||||
double missileChance;
|
||||
if (missile == 0 && support == 0) {
|
||||
missileChance = 0.5;
|
||||
} else {
|
||||
missileChance = support / (support + missile);
|
||||
}
|
||||
|
||||
if (random.nextDouble() > missileChance) {
|
||||
supportCount++;
|
||||
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
||||
} else {
|
||||
missileCount++;
|
||||
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
||||
}
|
||||
lastItemWasSupportItem = false;
|
||||
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren