use of micdoodle8.mods.galacticraft.api.entity.IAntiGrav in project Galacticraft by micdoodle8.
the class WorldUtil method getGravityFactor.
public static float getGravityFactor(Entity entity) {
if (entity.world.provider instanceof IGalacticraftWorldProvider) {
final IGalacticraftWorldProvider customProvider = (IGalacticraftWorldProvider) entity.world.provider;
float returnValue = MathHelper.sqrt(0.08F / (0.08F - customProvider.getGravity()));
if (returnValue > 2.5F) {
returnValue = 2.5F;
}
if (returnValue < 0.75F) {
returnValue = 0.75F;
}
return returnValue;
} else if (entity instanceof IAntiGrav) {
return 1F;
} else {
return 1F;
}
}
use of micdoodle8.mods.galacticraft.api.entity.IAntiGrav 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