use of micdoodle8.mods.galacticraft.api.item.IArmorGravity in project Galacticraft by micdoodle8.
the class TransformerHooks method getGravityForEntity.
public static double getGravityForEntity(Entity entity) {
if (entity.world.provider instanceof IGalacticraftWorldProvider) {
if (entity instanceof EntityChicken && !OxygenUtil.isAABBInBreathableAirBlock(entity.world, entity.getEntityBoundingBox())) {
return 0.08D;
}
final IGalacticraftWorldProvider customProvider = (IGalacticraftWorldProvider) entity.world.provider;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (player.inventory != null) {
int armorModLowGrav = 100;
int armorModHighGrav = 100;
for (ItemStack armorPiece : player.getArmorInventoryList()) {
if (armorPiece != null && armorPiece.getItem() instanceof IArmorGravity) {
armorModLowGrav -= ((IArmorGravity) armorPiece.getItem()).gravityOverrideIfLow(player);
armorModHighGrav -= ((IArmorGravity) armorPiece.getItem()).gravityOverrideIfHigh(player);
}
}
if (armorModLowGrav > 100) {
armorModLowGrav = 100;
}
if (armorModHighGrav > 100) {
armorModHighGrav = 100;
}
if (armorModLowGrav < 0) {
armorModLowGrav = 0;
}
if (armorModHighGrav < 0) {
armorModHighGrav = 0;
}
if (customProvider.getGravity() > 0) {
return 0.08D - (customProvider.getGravity() * armorModLowGrav) / 100;
}
return 0.08D - (customProvider.getGravity() * armorModHighGrav) / 100;
}
}
return 0.08D - customProvider.getGravity();
} else if (entity instanceof IAntiGrav) {
return 0;
} else {
return 0.08D;
}
}
Aggregations