use of micdoodle8.mods.galacticraft.api.item.IBreathableArmor in project Galacticraft by micdoodle8.
the class OxygenUtil method hasValidOxygenSetup.
public static boolean hasValidOxygenSetup(EntityPlayerMP player) {
boolean missingComponent = false;
GCPlayerStats stats = GCPlayerStats.get(player);
if (!OxygenUtil.isItemValidForPlayerTankInv(0, stats.getExtendedInventory().getStackInSlot(0))) {
boolean handled = false;
for (final ItemStack armorStack : player.inventory.armorInventory) {
if (!armorStack.isEmpty() && armorStack.getItem() instanceof IBreathableArmor) {
final IBreathableArmor breathableArmor = (IBreathableArmor) armorStack.getItem();
if (breathableArmor.handleGearType(EnumGearType.HELMET)) {
if (breathableArmor.canBreathe(armorStack, player, EnumGearType.HELMET)) {
handled = true;
}
}
}
}
if (!handled) {
missingComponent = true;
}
}
if (!OxygenUtil.isItemValidForPlayerTankInv(1, stats.getExtendedInventory().getStackInSlot(1))) {
boolean handled = false;
for (final ItemStack armorStack : player.inventory.armorInventory) {
if (!armorStack.isEmpty() && armorStack.getItem() instanceof IBreathableArmor) {
final IBreathableArmor breathableArmor = (IBreathableArmor) armorStack.getItem();
if (breathableArmor.handleGearType(EnumGearType.GEAR)) {
if (breathableArmor.canBreathe(armorStack, player, EnumGearType.GEAR)) {
handled = true;
}
}
}
}
if (!handled) {
missingComponent = true;
}
}
if (!OxygenUtil.isItemValidForPlayerTankInv(2, stats.getExtendedInventory().getStackInSlot(2)) && !OxygenUtil.isItemValidForPlayerTankInv(3, stats.getExtendedInventory().getStackInSlot(3))) {
boolean handled = false;
for (final ItemStack armorStack : player.inventory.armorInventory) {
if (!armorStack.isEmpty() && armorStack.getItem() instanceof IBreathableArmor) {
final IBreathableArmor breathableArmor = (IBreathableArmor) armorStack.getItem();
if (breathableArmor.handleGearType(EnumGearType.TANK1)) {
if (breathableArmor.canBreathe(armorStack, player, EnumGearType.TANK1)) {
handled = true;
}
}
if (breathableArmor.handleGearType(EnumGearType.TANK2)) {
if (breathableArmor.canBreathe(armorStack, player, EnumGearType.TANK2)) {
handled = true;
}
}
}
}
if (!handled) {
missingComponent = true;
}
}
return !missingComponent;
}
Aggregations