Search in sources :

Example 1 with IArmorGravity

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