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);
}
}
}
}
Aggregations