Search in sources :

Example 1 with ModuleLocomotiveBoostingUnit

use of mekanism.common.content.gear.mekasuit.ModuleLocomotiveBoostingUnit in project Mekanism by mekanism.

the class CommonPlayerTickHandler method onLivingJump.

@SubscribeEvent
public void onLivingJump(LivingJumpEvent event) {
    if (event.getEntityLiving() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getEntityLiving();
        IModule<ModuleHydraulicPropulsionUnit> module = MekanismAPI.getModuleHelper().load(player.getItemBySlot(EquipmentSlotType.FEET), MekanismModules.HYDRAULIC_PROPULSION_UNIT);
        if (module != null && module.isEnabled() && Mekanism.keyMap.has(player.getUUID(), KeySync.BOOST)) {
            float boost = module.getCustomInstance().getBoost();
            FloatingLong usage = MekanismConfig.gear.mekaSuitBaseJumpEnergyUsage.get().multiply(boost / 0.1F);
            IEnergyContainer energyContainer = module.getEnergyContainer();
            if (module.canUseEnergy(player, energyContainer, usage, false)) {
                // if we're sprinting with the boost module, limit the height
                IModule<ModuleLocomotiveBoostingUnit> boostModule = MekanismAPI.getModuleHelper().load(player.getItemBySlot(EquipmentSlotType.LEGS), MekanismModules.LOCOMOTIVE_BOOSTING_UNIT);
                if (boostModule != null && boostModule.isEnabled() && boostModule.getCustomInstance().canFunction(boostModule, player)) {
                    boost = (float) Math.sqrt(boost);
                }
                player.setDeltaMovement(player.getDeltaMovement().add(0, boost, 0));
                module.useEnergy(player, energyContainer, usage, true);
            }
        }
    }
}
Also used : FloatingLong(mekanism.api.math.FloatingLong) ModuleLocomotiveBoostingUnit(mekanism.common.content.gear.mekasuit.ModuleLocomotiveBoostingUnit) IEnergyContainer(mekanism.api.energy.IEnergyContainer) ModuleHydraulicPropulsionUnit(mekanism.common.content.gear.mekasuit.ModuleHydraulicPropulsionUnit) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

IEnergyContainer (mekanism.api.energy.IEnergyContainer)1 FloatingLong (mekanism.api.math.FloatingLong)1 ModuleHydraulicPropulsionUnit (mekanism.common.content.gear.mekasuit.ModuleHydraulicPropulsionUnit)1 ModuleLocomotiveBoostingUnit (mekanism.common.content.gear.mekasuit.ModuleLocomotiveBoostingUnit)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1