SteamWar/MissileWars
Archiviert
13
0

Fix many item things!
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-08-01 10:17:48 +02:00
Ursprung 4c68900162
Commit 95457509aa
3 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -104,6 +104,11 @@ public class MWTeam {
Inventory inventory = p.getInventory(); Inventory inventory = p.getInventory();
for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot
ItemStack itemStack = inventory.getItem(i); ItemStack itemStack = inventory.getItem(i);
if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
inventory.setItem(i, itemStack);
return;
}
if (itemStack != null && itemStack.getType() == item.getType() && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) { if (itemStack != null && itemStack.getType() == item.getType() && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) {
int uses = getUsesOfItem(itemStack) + getUsesOfItem(item); int uses = getUsesOfItem(itemStack) + getUsesOfItem(item);
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
@ -112,10 +117,6 @@ public class MWTeam {
itemStack.setItemMeta(damageable); itemStack.setItemMeta(damageable);
inventory.setItem(i, itemStack); inventory.setItem(i, itemStack);
return; return;
} else if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
inventory.setItem(i, itemStack);
return;
} }
} }

Datei anzeigen

@ -41,11 +41,6 @@ public class ItemCountdown extends StateDependent {
} }
private void run() { private void run() {
if (currenTime == 0) {
ItemStack itemStack = SpecialItem.getRandomItem();
MissileWars.getBlueTeam().givePlayerItem(itemStack);
MissileWars.getRedTeam().givePlayerItem(itemStack);
}
currenTime++; currenTime++;
int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size()); int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size());

Datei anzeigen

@ -40,7 +40,8 @@ import java.util.Random;
public abstract class SpecialItem { public abstract class SpecialItem {
private static final Random random = new Random(); private static final Random random = new Random();
private static long count = 0; private static double count = 0;
private static int consecutiveSupportItems = 0;
private static List<SpecialItem> supportItems = new ArrayList<>(); private static List<SpecialItem> supportItems = new ArrayList<>();
private static List<SpecialItem> missileItems = new ArrayList<>(); private static List<SpecialItem> missileItems = new ArrayList<>();
@ -110,14 +111,21 @@ public abstract class SpecialItem {
} }
public static ItemStack getRandomItem() { public static ItemStack getRandomItem() {
if (Config.MissileChance == 0 || consecutiveSupportItems > 1) {
consecutiveSupportItems = 0;
return supportItems.get(random.nextInt(supportItems.size())).getItem();
}
if (Config.MissileChance == 1) {
return missileItems.get(random.nextInt(missileItems.size())).getItem();
}
double missileChance = Config.MissileChance + count * 0.1; double missileChance = Config.MissileChance + count * 0.1;
if (Config.MissileChance == 0) missileChance = 0.0;
if (Config.MissileChance == 1) missileChance = 1.0;
if (random.nextDouble() > missileChance) { if (random.nextDouble() > missileChance) {
count++; count += Config.MissileChance;
consecutiveSupportItems++;
return supportItems.get(random.nextInt(supportItems.size())).getItem(); return supportItems.get(random.nextInt(supportItems.size())).getItem();
} else { } else {
count--; count -= 1 - Config.MissileChance;
return missileItems.get(random.nextInt(missileItems.size())).getItem(); return missileItems.get(random.nextInt(missileItems.size())).getItem();
} }
} }