Search in sources :

Example 1 with IAntiGrav

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;
    }
}
Also used : IAntiGrav(micdoodle8.mods.galacticraft.api.entity.IAntiGrav) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)

Example 2 with IAntiGrav

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;
    }
}
Also used : IAntiGrav(micdoodle8.mods.galacticraft.api.entity.IAntiGrav) EntityChicken(net.minecraft.entity.passive.EntityChicken) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) IArmorGravity(micdoodle8.mods.galacticraft.api.item.IArmorGravity)

Aggregations

IAntiGrav (micdoodle8.mods.galacticraft.api.entity.IAntiGrav)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)2 IArmorGravity (micdoodle8.mods.galacticraft.api.item.IArmorGravity)1 EntityChicken (net.minecraft.entity.passive.EntityChicken)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1